문제링크
https://www.acmicpc.net/problem/20124
package BOJ;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main_20124 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Node[] node = new Node[N];
for(int i=0;i<N;i++){
StringTokenizer st = new StringTokenizer(br.readLine());
String name = st.nextToken();
int score = Integer.parseInt(st.nextToken());
node[i] = new Node(score,name);
}
Arrays.sort(node);
System.out.println(node[0].name);
}
static class Node implements Comparable<Node>{
int score;
String name;
public Node(int score,String name) {
this.score = score;
this.name = name;
}
@Override
public int compareTo(Node o) {
if(this.score == o.score)
return this.name.compareTo(o.name);
else
return o.score-this.score;
}
}
}
'알고리즘 > 백준' 카테고리의 다른 글
[JAVA]백준_1389_케빈 베이컨의 6단계 법칙 (0) | 2021.04.21 |
---|---|
[JAVA]백준_20113_긴급회의 (0) | 2021.04.21 |
[JAVA]백준_20499_Darius님 한타 안 함? (0) | 2021.04.21 |
[JAVA]백준_11403_경로찾기 (0) | 2021.04.21 |
[JAVA]백준_11562_백양로 브레이크 (0) | 2021.04.21 |