Skip to content

Commit b47e6d6

Browse files
committed
1 parent 5a1ab9b commit b47e6d6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}

0 commit comments

Comments
 (0)