結果

問題 No.406 鴨等間隔の法則
ユーザー swdamdrswdamdr
提出日時 2017-01-26 14:52:33
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 962 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 107,136 KB
実行使用メモリ 28,556 KB
最終ジャッジ日時 2024-04-24 21:52:50
合計ジャッジ時間 11,100 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
28,556 KB
testcase_01 AC 27 ms
19,200 KB
testcase_02 AC 25 ms
19,200 KB
testcase_03 AC 24 ms
18,944 KB
testcase_04 AC 193 ms
27,648 KB
testcase_05 AC 974 ms
22,692 KB
testcase_06 AC 118 ms
22,572 KB
testcase_07 AC 102 ms
22,884 KB
testcase_08 AC 378 ms
27,520 KB
testcase_09 AC 572 ms
28,160 KB
testcase_10 AC 404 ms
23,064 KB
testcase_11 AC 697 ms
26,240 KB
testcase_12 AC 729 ms
23,360 KB
testcase_13 AC 120 ms
24,064 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray();
        Array.Sort(a);
        string ans = "YES";

        if (Judge(a))
        {
            for (int i = 0; i < n - 2; i++)
            {
                if (a[i] - a[i + 1] != a[i + 1] - a[i + 2])
                {
                    ans = "NO";
                    break;
                }
            }
        }
        else
        {
            ans = "NO";
        }

        Console.WriteLine(ans);
        Console.Read();
    }

    static bool Judge(int[] a)
    {
        int len = a.Length;

        for (int i = 0; i < len - 1; i++)
        {
            if (Array.LastIndexOf(a, a[i]) != i)
            {
                return false;
            }
        }
        return true;
    }
}

0