-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_1015.java
More file actions
36 lines (31 loc) · 1017 Bytes
/
Copy pathBOJ_1015.java
File metadata and controls
36 lines (31 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// BOJ - 1015
// Problem Sheet - https://www.acmicpc.net/problem/1015
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int n = Integer.parseInt(bf.readLine());
int[][] elements = new int[n][2];
StringTokenizer st = new StringTokenizer(bf.readLine());
for(int i=0 ; i<n ; i++) {
elements[i][0] = Integer.parseInt(st.nextToken());
elements[i][1] = i;
}
Arrays.sort(elements, (e1, e2) -> {
return e1[0] - e2[0];
});
int[] p = new int[n];
for(int i=0 ; i<n ; i++) {
p[elements[i][1]] = i;
}
for(int i=0 ; i<n ; i++) {
sb.append(p[i]).append(" ");
}
sb.append("\n");
System.out.println(sb);
bf.close();
System.exit(0);
}
}