ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • boj)10989
    PS/boj 2020. 8. 28. 18:11
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    
    public class Main {
        public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    
            int N = Integer.parseInt(br.readLine());
            int[] ans = new int[10001];
    
            for (int i = 0; i < N; i++) { // N
                ans[Integer.parseInt(br.readLine())]++;
            }
    
            for (int i = 0; i < ans.length; i++) {
                if (ans[i] != 0) {
                    for (int j = 0; j < ans[i]; j++) {
                        bw.write(Integer.toString(i) + "\n");
                    }
                }
            }
    
            br.close();
            bw.close();
        }
    
    }

     

    - 계층정렬해야 하는거 생각 했는데 계속 시간초과 걸려서 못품

    - print 말고 BufferedWriter로 출력해야함 

     

     


    https://www.acmicpc.net/problem/10989

    'PS > boj' 카테고리의 다른 글

    boj)2523  (0) 2020.08.29
    boj)1110  (0) 2020.08.29
    boj)1431  (0) 2020.08.28
    boj)1181  (0) 2020.08.28
    boj)5585  (0) 2020.08.24
킹수빈닷컴