File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
java/inflearn/problemsolving Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // https://cote.inflearn.com/contest/10/problem/02-08
2+ package inflearn .problemsolving ;
3+
4+ import java .util .*;
5+ import java .util .stream .Collectors ;
6+
7+ public class P02_08_등수구하기 {
8+ public static List <Integer > solve (int n , int [] arr ) {
9+ List <Integer > answer = new ArrayList <>();
10+ List <Integer > sortedArr = Arrays .stream (arr ).
11+ boxed ().
12+ sorted (Comparator .reverseOrder ()).
13+ collect (Collectors .toList ());
14+
15+ for (int i = 0 ; i < n ; i ++) {
16+ int index = sortedArr .indexOf (arr [i ]) + 1 ;
17+ answer .add (index );
18+ }
19+
20+ return answer ;
21+ }
22+
23+ public static void main (String [] args ) {
24+ // 5
25+ // 87 89 92 100 76 => 4 3 2 1 5
26+ Scanner in = new Scanner (System .in );
27+ int n = in .nextInt ();
28+
29+ int [] arr = new int [n ];
30+ for (int i = 0 ; i < n ; i ++) {
31+ arr [i ] = in .nextInt ();
32+ }
33+
34+ for (int x : solve (n , arr )) System .out .print (x + " " );
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments