import java.util.*;
import java.io.*;
public class acm {
private static class IntPair implements Comparable<IntPair> {
public int a, b;
public IntPair(int a, int b) {
this.a = a;
this.b = b;
}
public int compareTo(IntPair i) {
if (i.a != this.a) return this.a - i.a;
return i.b - this.b;
}
}
private static class Ranking implements Comparable<Ranking> {
public String team;
public IntPair score;
public Ranking(String team, IntPair score) {
this.team = team;
this.score = score;
}
public int compareTo(Ranking i) {
if (this.score.compareTo(i.score) != 0) return this.score.compareTo(i.score);
return i.team.compareTo(this.team);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt(), M = sc.nextInt();
ArrayList<Ranking> arr = new ArrayList<Ranking>();
for (int i = 0; i < N; ++i) {
String team = sc.next();
IntPair score = new IntPair(0, 0);
for (int j = 0; j < M; ++j) {
String res = sc.next();
if (res.charAt(0) != '-') {
++score.a;
int time = 0;
time += 1200 * (res.charAt(1) - '0');
time += 3600 * Integer.parseInt(res.substring(3, 5)) + 60 * Integer.parseInt(res.substring(6, 8)) + Integer.parseInt(res.substring(9, 11));
score.b += time;
}
}
if (!team.equals("NijeZivotJedanACM")) arr.add(new Ranking(team, score));
}
Collections.sort(arr);
Ranking nijeRanking;
String team = sc.next();
IntPair score = new IntPair(0, 0);
for (int j = 0; j < M; ++j) {
String res = sc.next();
if (res.charAt(0) != '-') {
++score.a;
int time = 0;
time += 1200 * (res.charAt(1) - '0');
time += 3600 * Integer.parseInt(res.substring(3, 5)) + 60 * Integer.parseInt(res.substring(6, 8)) + Integer.parseInt(res.substring(9, 11));
score.b += time;
}
}
nijeRanking = new Ranking(team, score);
for (int i = 1; i <= arr.size(); ++i) {
if (nijeRanking.compareTo(arr.get(arr.size() - i)) > 0) {
System.out.println(i);
return;
}
}
System.out.println(N);
return;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
12568 KB |
Output is correct |
2 |
Correct |
409 ms |
29904 KB |
Output is correct |
3 |
Correct |
127 ms |
11792 KB |
Output is correct |
4 |
Correct |
370 ms |
30136 KB |
Output is correct |
5 |
Correct |
385 ms |
29976 KB |
Output is correct |