1 条题解

  • 0
    @ 2025-4-12 22:06:18

    Java :

    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    		// TODO 自动生成的方法存根
    		Scanner input = new Scanner(System.in);
    		int n = input.nextInt();
    		int i = 1;
    		String A = input.next();
    		double scoreA = input.nextDouble();
    		double scoreB = scoreA;
    		String B = A;
    		if (n == 1) {
    			System.out.print(A);
    		} 
    		else {
    			while (i < n) {
    				String C = input.next();
    				double scoreC = input.nextDouble();
    				if (scoreC > scoreA) {
    					scoreB = scoreA;
    					B = A;
    					scoreA = scoreC;
    					A = C;
    				} 
    				else {
    					if (scoreC > scoreB) {
    						scoreB = scoreC;
    						B = C;
    					}
    				}
    				i = i + 1;
    			}
    			System.out.print(A +" " + B);
    		}
    	}
    
    }
    
    • 1

    信息

    ID
    2960
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者