結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
|
提出日時 | 2017-08-27 22:21:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 75,444 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 12:10:16 |
合計ジャッジ時間 | 2,467 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<int> x(n); for(int i = 0; i < n; i++){ cin >> x[i]; } sort(x.begin(), x.end()); int start = x[1]; int inte = x[1]-x[0]; if(inte == 0){ cout << "NO" << endl; } else { int pos = start; for(int i = 2; i < n; i++){ if(x[i] != pos+inte){ cout << "NO" << endl; return 0; } pos = x[i]; } cout << "YES" << endl; } return 0; }