-
[java]백준 Yangjojang of The Year 11557번알고리즘 문제풀이/백준(자바) 2023. 5. 8. 22:42
코드
import java.util.Scanner; public class BOJ_11557 { public static void main(String[] args) { Scanner in =new Scanner(System.in); int t= in.nextInt();//케이스 for (int i = 0; i < t; i++) { int n=in.nextInt();//학교의 숫자 정수 N String[] a=new String[n];//학교이름 int[] b=new int[n];//지난 한 해동안 소비한 술의 양 for (int j = 0; j < n; j++) { a[j]=in.next(); b[j]=in.nextInt(); } int max=0; int s=0; for (int j = 0; j < b.length; j++) { if(max<b[j]){//b에서 max이면 s=인덱스할당 max=b[j]; s=j; } } System.out.println(a[s]);//그래서 a에서 s인덱스 출력 } in.close(); } }
링크
https://www.acmicpc.net/problem/11557
'알고리즘 문제풀이 > 백준(자바)' 카테고리의 다른 글
[java]백준 Hook 10189번 (0) 2023.05.10 [java]백준 세수정렬 2752번 (0) 2023.05.09 [java]백준 팬들에게 둘러싸인 홍준 14581번 (0) 2023.05.07 [java]백준 그대로 출력하기 2 11719번 (0) 2023.05.06 [java]백준 입실 관리 5524번 (0) 2023.05.05