File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .*;
2+
3+ public class Main {
4+
5+ public static void main (String [] args ) throws IOException {
6+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
7+ int N = Integer .parseInt (br .readLine ());
8+ int [] arr = new int [N ];
9+ int [] count = new int [10002 ];
10+ int [] sortedArr = new int [N ];
11+ for (int i =0 ; i <N ; i ++) {
12+ arr [i ] = Integer .parseInt (br .readLine ());
13+ count [arr [i ]]++;
14+ }
15+ for (int i =1 ; i <=10000 ; i ++) {
16+ count [i ] += count [i -1 ];
17+ }
18+ for (int i =0 ; i <N ; i ++) {
19+ int n = arr [i ];
20+ count [n ]--;
21+ sortedArr [count [n ]] = n ;
22+ }
23+ StringBuffer sb = new StringBuffer ();
24+ for (int i =0 ; i <N ; i ++) {
25+ sb .append (sortedArr [i ]).append ('\n' );
26+ }
27+ System .out .print (sb );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments