結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
|
提出日時 | 2019-08-31 08:27:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 1,500 ms |
コンパイル使用メモリ | 173,328 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 12:42:17 |
合計ジャッジ時間 | 3,300 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
/** @file 406.cpp @title No.406 鴨等間隔の法則 - yukicoder @url https://yukicoder.me/problems/no/406 **/ #include <bits/stdc++.h> using namespace std; typedef long long LL; #define ALL(obj) (obj).begin(), (obj).end() #define REP(i, N) for (int i = 0; i < (N); ++i) int main() { LL N; cin >> N; vector<LL> x(N, 0); REP(i, N) { cin >> x[i]; } sort(ALL(x)); LL gap = abs(x[0] - x[1]); LL count = 0; REP(i, N - 1) { LL res = abs(x[i] - x[i + 1]); if (res == 0 || gap != res) count++; } string ans = (count == 0) ? "YES" : "NO"; cout << ans << endl; return 0; }