結果

問題 No.185 和風
ユーザー CroweaCrowea
提出日時 2019-01-26 13:42:53
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 722 bytes
コンパイル時間 1,236 ms
コンパイル使用メモリ 67,900 KB
実行使用メモリ 24,568 KB
最終ジャッジ日時 2023-10-14 09:59:31
合計ジャッジ時間 2,000 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
22,500 KB
testcase_01 AC 68 ms
24,568 KB
testcase_02 WA -
testcase_03 AC 69 ms
22,396 KB
testcase_04 AC 66 ms
22,372 KB
testcase_05 AC 64 ms
22,636 KB
testcase_06 AC 68 ms
22,668 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;
        var result = 0;
        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            result = input[1] - input[0];
            if (result >= 1) set.Add(result);
        }
        if (set.Count() == 0) Console.WriteLine(-1);
        else
        {
            var count = set.Distinct().Count();
            var ans = set.First();
            Console.WriteLine((count == 1) ? ans : -1);
        }
    }
}

0