Skip to content

Commit 560d7a4

Browse files
authored
[BOJ] 15906 스텔라가 치킨을 선물했어요 (S5)
1 parent ef6d0ae commit 560d7a4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

정건우/4주차/260119.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//https://www.acmicpc.net/problem/15905
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.util.ArrayList;
6+
import java.util.Collections;
7+
import java.util.List;
8+
import java.util.StringTokenizer;
9+
10+
public class BOJ_S5_15906_스텔라가치킨을선물했어요 {
11+
static class Student implements Comparable<Student> {
12+
int score;
13+
int penalty;
14+
15+
public Student(int score, int penalty) {
16+
this.score = score;
17+
this.penalty = penalty;
18+
}
19+
20+
@Override
21+
public int compareTo(Student o) {
22+
if(this.score != o.score) {
23+
return Integer.compare(o.score, this.score);
24+
}
25+
26+
return Integer.compare(this.penalty, o.penalty);
27+
}
28+
}
29+
30+
public static void main(String[] args) throws IOException {
31+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
32+
33+
int N = Integer.parseInt(br.readLine());
34+
List<Student> students = new ArrayList<>();
35+
36+
StringTokenizer st;
37+
for(int i = 0; i < N; i++) {
38+
st = new StringTokenizer(br.readLine());
39+
int score = Integer.parseInt(st.nextToken());
40+
int penalty = Integer.parseInt(st.nextToken());
41+
42+
students.add(new Student(score, penalty));
43+
}
44+
45+
Collections.sort(students);
46+
47+
int fifthScore = students.get(4).score;
48+
int ans = 0;
49+
50+
for(int i = 5; i < N; i++) {
51+
if(fifthScore != students.get(i).score) break;
52+
53+
ans++;
54+
}
55+
56+
System.out.println(ans);
57+
58+
}
59+
}

0 commit comments

Comments
 (0)