結果
| 問題 | No.406 鴨等間隔の法則 |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-04-16 06:50:59 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 687 bytes |
| 記録 | |
| コンパイル時間 | 185 ms |
| コンパイル使用メモリ | 37,888 KB |
| 最終ジャッジ日時 | 2026-02-22 03:00:22 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
// yukicoder: No.406 鴨等間隔の法則
// 2019.4.16 bal4u
#include <stdio.h>
#include <stdlib.h>
//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in() // 非負整数の入力
{
int n = 0, c = gc();
do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
return n;
}
int N;
int x[100005];
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main()
{
int i, d;
N = in();
for (i = 0; i < N; i++) x[i] = in();
qsort(x, N, sizeof(int), cmp);
d = x[1] - x[0];
if (d == 0) puts("NO");
else {
for (i = 2; i < N; i++) if (x[i] - x[i - 1] != d) break;
puts(i >= N ? "YES" : "NO");
}
return 0;
}
bal4u