728x90
반응형
야 류찬. 생일 축하해.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String args[]) { | |
Scanner sc = new Scanner(System.in); | |
int N = sc.nextInt(); | |
String chan[][] = new String[N][4]; | |
for (int i=0; i<N; i++) { | |
chan[i][0] = sc.next(); | |
chan[i][1] = sc.next(); | |
chan[i][2] = sc.next(); | |
chan[i][3] = sc.next(); | |
} | |
Arrays.sort(chan, new Comparator<String[]>() { | |
@Override | |
public int compare(String[] o1, String[] o2) { | |
if (Integer.parseInt(o1[3]) == Integer.parseInt(o2[3])) { | |
if (Integer.parseInt(o1[2]) == Integer.parseInt(o2[2])) { | |
return Integer.compare(Integer.parseInt(o1[1]), Integer.parseInt(o2[1])); | |
} else | |
return Integer.compare(Integer.parseInt(o1[2]), Integer.parseInt(o2[2])); | |
} | |
return Integer.compare(Integer.parseInt(o1[3]), Integer.parseInt(o2[3])); | |
} | |
}); | |
System.out.println(chan[N-1][0] + "\n" + chan[0][0]); | |
} | |
} |
반응형
'알고리즘 공부' 카테고리의 다른 글
[HackerRank] repeated-string java 풀이 (0) | 2024.10.08 |
---|---|
[HackerRank] Jumping on the Clouds java 풀이 (0) | 2024.10.07 |
[백준 2133번] 타일 채우기 - java (0) | 2022.05.15 |
[백준 14940번] 쉬운 최단거리 - java (0) | 2022.04.19 |
[백준 12934번] 턴 게임 - java (0) | 2022.04.19 |