-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
62 lines (45 loc) · 1.49 KB
/
Main.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package kakao.blind.test2019.num2;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();// stage 갯수
int stage[] = { 2, 1, 2, 6, 2, 4, 3, 3 }; // 각 user들이 도달해 있는 단계
int userNum = stage.length; // user 수
Vector<Double> failure = new Vector<Double>();
ArrayList<Double> temp = new ArrayList<Double>(); // failure의 sort된 형태
ArrayList<Integer> result = new ArrayList<Integer>(); // 결과 배열. failure의 index가 들어옴
int cnt[] = new int[n]; // 각 스테이지에 머물고 있는 사람
for (int i = 0; i < stage.length; i++) {
for (int j = 1; j < n + 1; j++) {
if (stage[i] == j) {
cnt[j - 1]++;
}
}
}
// for(int i=0;i<n;i++) {
// System.out.println(cnt[i]);
// }
// System.out.println("==========");
for (int i = 0; i < n; i++) {
failure.add((double) cnt[i] / userNum);
userNum -= cnt[i];
// System.out.println(failure.get(i));
temp.add(failure.get(i));
}
temp.sort(Comparator.reverseOrder());
// System.out.println("" + temp.toString());
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (failure.get(j) == temp.get(i)) {
result.add(j + 1);
break;
}
}
}
System.out.println("" + result.toString());
}
}