結果
問題 | No.406 鴨等間隔の法則 |
ユーザー |
![]() |
提出日時 | 2017-09-29 12:54:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 85,472 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 12:11:07 |
合計ジャッジ時間 | 2,545 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <cmath> #include <fstream> #include <set> #include <utility> #include <algorithm> using namespace std; int max(int x, int y) { int a; (x > y) ? a = x : a = y; return a; } int min(int x, int y) { int a; (x < y) ? a = x : a = y; return a; } int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++)cin >> v[i]; sort(v.begin(), v.end()); bool judge = true; int diff = v[1] - v[0]; if (diff != 0) { for (int i = 1; i < n; i++) { if (v[i] - v[i - 1] != diff)judge = false; } } else judge = false; if (judge)cout << "YES" << endl; else cout << "NO" << endl; return 0; }