백준

백준 11557번 문제 Yangjojang of The Year (Java)

gxxgsta 2021. 5. 14. 11:57
반응형
SMALL
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	
    	int T = Integer.parseInt(sc.nextLine());
    	int num=-1;
    	
    	for(int i=0; i<T; i++) {
    		int N = Integer.parseInt(sc.nextLine());
			int[] alcol = new int[N];
			String[] school = new String[N];
    		for(int j=0; j<N; j++) {
    			String s = sc.nextLine();
    			String[] S = s.split(" ");
    			alcol[j] = Integer.parseInt(S[1]);
    			school[j] = S[0];
    		}
    		int max = -1;
			for(int j=0; j<N; j++) {
				if(alcol[j]>max) {
					max=alcol[j];
					num=j;
				}
			}
			System.out.println(school[num]);
    	}
    }
}
반응형
LIST