結果

問題 No.185 和風
ユーザー CroweaCrowea
提出日時 2019-01-26 14:06:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 1,000 ms
コード長 658 bytes
コンパイル時間 1,665 ms
コンパイル使用メモリ 69,852 KB
実行使用メモリ 24,700 KB
最終ジャッジ日時 2023-10-14 10:10:19
合計ジャッジ時間 2,110 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
22,564 KB
testcase_01 AC 61 ms
22,692 KB
testcase_02 AC 60 ms
22,552 KB
testcase_03 AC 59 ms
22,552 KB
testcase_04 AC 61 ms
22,564 KB
testcase_05 AC 61 ms
22,612 KB
testcase_06 AC 62 ms
24,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var set = new HashSet<int>();

        int[] input;
        int ans = 0;
        while (N > 0)
        {
            input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            input[1] -= input[0];
            if (input[1] <= 0) { Console.WriteLine(-1); return; }
            if (ans == 0) ans = input[1];
            else if (ans != input[1]) { Console.WriteLine("-1"); return; }
            N--;
        }
        Console.WriteLine(ans);
    }
}

0