結果
| 問題 |
No.406 鴨等間隔の法則
|
| ユーザー |
14番
|
| 提出日時 | 2016-09-01 09:22:06 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 1,900 bytes |
| コンパイル時間 | 1,031 ms |
| コンパイル使用メモリ | 115,388 KB |
| 実行使用メモリ | 35,072 KB |
| 最終ジャッジ日時 | 2024-07-07 11:42:11 |
| 合計ジャッジ時間 | 4,221 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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.OrderBy(a=>a).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 = @"
";
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();
}
}
14番