結果

問題 No.406 鴨等間隔の法則
ユーザー 14番
提出日時 2016-09-01 09:16:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,903 bytes
コンパイル時間 4,622 ms
コンパイル使用メモリ 108,288 KB
実行使用メモリ 34,176 KB
最終ジャッジ日時 2024-11-07 05:34:21
合計ジャッジ時間 5,683 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 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;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int kamoCount = int.Parse(Reader.ReadLine());
        int[] kamoList = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        Dictionary<int, bool> dic = new Dictionary<int, bool>();

        string ans = "YES";
        for (int i = 0; i < kamoList.Length; i++)
        {
            if (dic.ContainsKey(kamoList[i]))
            {
                ans = "NO";
                break;
            }
            dic.Add(kamoList[i], true);
        }

        if (ans.Equals("YES"))
        {
            List<int> keys = dic.Keys.ToList();
            int prev = -1;
            for (int i = 1; i < keys.Count; i++)
            {
                if (prev > 0)
                {
                    if (prev != keys[i] - keys[i - 1])
                    {
                        ans = "NO";
                        break;
                    }
                }
                else
                {
                    prev = keys[i] - keys[i - 1];
                }
            }
        }
        Console.WriteLine(ans);

    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


5
63 17 99 34 51



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0