-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_1205
More file actions
44 lines (32 loc) · 1.01 KB
/
BAEKJOON_1205
File metadata and controls
44 lines (32 loc) · 1.01 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
42
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt(); //리스트에 있는 점수
int score = scanner.nextInt(); //태수 점수
int P = scanner.nextInt(); //랭킹 리스트에 올라갈 수 있는 점수 개수
Integer[] arr = new Integer[N];
if(N==0){
System.out.print(1);
System.exit(0);
}
for(int i=0; i<N; i++){
arr[i] = scanner.nextInt();
}
Arrays.sort(arr, Collections.reverseOrder());
if (score <= arr[arr.length - 1] && N == P) {
System.out.print(-1);
}else{
int rank =1;
for(int i=0; i<N; i++){
if (score < arr[i]) {
rank++;
}else{
break;
}
}
System.out.print(rank);
}
}
}