結果

問題 No.1109 調の判定
ユーザー bluemegane
提出日時 2020-07-11 16:28:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 2,442 ms
コンパイル使用メモリ 113,252 KB
実行使用メモリ 26,724 KB
最終ジャッジ日時 2024-10-13 04:58:12
合計ジャッジ時間 4,803 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        if (n == 1) { Console.WriteLine(-1); return; }
        var count = 0;
        var ansi = 0;
        for (int i = 0; i < n; i++)
        {
            if (check(n, a, i)) { ansi = i; count++; }
        }
        Console.WriteLine(count == 1 ? a[ansi] : -1);
    }
    static bool check(int n, int[] a, int t)
    {
        var c = new int[] { 0, 2, 4, 5, 7, 9, 11 };
        var d = a[t];
        foreach (var x in a)
        {
            var y = x - d;
            if (y < 0) y += 12;
            y %= 12;
            if (!c.Contains(y)) return false;
        }
        return true;
    }
}
0