結果
| 問題 |
No.406 鴨等間隔の法則
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-26 14:52:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 962 bytes |
| コンパイル時間 | 2,575 ms |
| コンパイル使用メモリ | 106,752 KB |
| 実行使用メモリ | 31,744 KB |
| 最終ジャッジ日時 | 2024-11-07 07:01:59 |
| 合計ジャッジ時間 | 11,087 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 TLE * 1 -- * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}