結果

問題 No.185 和風
ユーザー Lo_OTLo_OT
提出日時 2018-03-13 18:28:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 183 ms / 1,000 ms
コード長 622 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 73,780 KB
実行使用メモリ 43,580 KB
最終ジャッジ日時 2024-05-02 02:17:08
合計ジャッジ時間 3,497 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
41,804 KB
testcase_01 AC 183 ms
43,160 KB
testcase_02 AC 114 ms
41,128 KB
testcase_03 AC 109 ms
41,032 KB
testcase_04 AC 111 ms
41,276 KB
testcase_05 AC 96 ms
39,992 KB
testcase_06 AC 180 ms
43,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
     public static void main(String []args){
         Scanner in = new Scanner(System.in);
         int loops = in.nextInt();
         int x = in.nextInt(), y = in.nextInt();
         int ans = y - x;
         
         if(ans <= 0){
             System.out.println(-1);
             return;
         }
         
         while(in.hasNextInt()){
             x = in.nextInt();
             y = in.nextInt();
             if(ans != (y - x)){
                 System.out.println(-1);
                 return;
             }
         }
         System.out.println(ans);
     }
}
0