WA

2j1ejyu Reply 6 years 5 weeks ago
왜 틀렸나요 샘플은 맞던데 ㅜㅜ import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int people = input.nextInt(); input.nextLine(); String[] employee = new String[people]; int[] time = new int[people]; for(int i=0; i<people; i++){ employee[i] = input.next(); int sum = 0; for(int j=0; j<7; j++){ int k = input.nextInt(); sum += k; } time[i] = sum; } for(int i=0; i<people; i++){ for(int j=i; j<people; j++){ if(time[j]>time[i]){ int temp1 = time[j]; time[j] = time[i]; time[i] = temp1; String temp2 = employee[i]; employee[i] = employee[j]; employee[j] = temp2; } } } for(int i=0; i<people; i++){ System.out.print(employee[i]+" "+time[i]); if(i<people-1) System.out.println(); } } }
Hyunwoo Reply 6 years 5 weeks ago
만약 employee3 과 employee16의 일한 시간이 같다면 employee3 부터 출력되어야 합니다. 현재 코드는 그렇지 않아 WA가 나왔습니다.