-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoj_18870.java
More file actions
41 lines (32 loc) · 1.02 KB
/
Boj_18870.java
File metadata and controls
41 lines (32 loc) · 1.02 KB
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
37
38
39
40
41
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Boj_18870 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] arr = new int[N];
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
for(int i=0;i<N;i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
int[] sortnum = arr.clone(); // ¹è¿ º¹»ç
Arrays.sort(sortnum); // Á¤·Ä (Áߺ¹ Á¦°Å)
Map<Integer, Integer> map = new HashMap<>();
int cnt=0;
for(int i=0;i<sortnum.length;i++) {
if(!map.containsKey(sortnum[i])) {
map.put(sortnum[i], cnt++);
}
}
StringBuilder sb = new StringBuilder();
for(int i=0;i<arr.length;i++) {
sb.append(map.get(arr[i])+" ");
}
System.out.print(sb);
}
}