-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_11557.java
More file actions
46 lines (37 loc) · 1.41 KB
/
Copy pathBOJ_11557.java
File metadata and controls
46 lines (37 loc) · 1.41 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
43
44
45
46
// BOJ - 11557
// Problem Sheet - https://www.acmicpc.net/problem/11557
import java.util.*;
import java.io.*;
public class Main {
static class University {
private final String name;
private final int quantity;
public University(String name, int quantity) {
this.name = name;
this.quantity = quantity;
}
public String getName() { return this.name; }
public int getQuantity() { return this.quantity; }
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
StringTokenizer st;
int t = Integer.parseInt(br.readLine());
for (int i=0 ; i<t ; i++) {
int n = Integer.parseInt(br.readLine());
University[] universities = new University[n];
for (int j=0 ; j<n ; j++) {
st = new StringTokenizer(br.readLine());
String name = st.nextToken();
int quantity = Integer.parseInt(st.nextToken());
universities[j] = new University(name, quantity);
}
Arrays.sort(universities, (u1, u2) -> u2.getQuantity() - u1.getQuantity());
sb.append(universities[0].getName()).append("\n");
}
System.out.println(sb);
br.close();
System.exit(0);
}
}