結果

問題 No.185 和風
ユーザー fungsi
提出日時 2025-09-21 17:41:36
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 7,199 ms
コンパイル使用メモリ 78,416 KB
実行使用メモリ 50,868 KB
最終ジャッジ日時 2025-09-21 17:41:46
合計ジャッジ時間 4,993 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int n = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
        }
        
        int result = -1;
        List<Integer> vec = new ArrayList<>();
        
        for (int i = 0; i < n; i++) {
            vec.add(b[i] - a[i]);
        }
        
        Collections.sort(vec);
        
        if (vec.get(0) == vec.get(vec.size() - 1) && vec.get(vec.size() - 1) > 0) {
            result = vec.get(vec.size() - 1);
        }
        
        System.out.println(result);
    }
}
0