結果

問題 No.185 和風
ユーザー CroweaCrowea
提出日時 2019-01-26 13:54:34
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 61,868 KB
実行使用メモリ 22,812 KB
最終ジャッジ日時 2023-10-14 09:59:52
合計ジャッジ時間 1,966 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
22,636 KB
testcase_01 WA -
testcase_02 AC 64 ms
22,712 KB
testcase_03 AC 65 ms
20,772 KB
testcase_04 AC 65 ms
22,680 KB
testcase_05 AC 64 ms
22,604 KB
testcase_06 AC 69 ms
22,652 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 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var ans = input[1] - input[0];
        if (ans <= 0)
        {
            Console.WriteLine(-1);
            return;
        }

        var result = 0;
        for (int i = 0; i < N - 1; i++)
        {
            input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            result = input[1] - input[0];
            if (result == ans) set.Add(result);
        }

        Console.WriteLine((set.Count() == 1) ? set.First() : -1);
}
}

0