結果
問題 |
No.1884 Sequence
|
ユーザー |
|
提出日時 | 2022-03-25 23:28:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 918 bytes |
コンパイル時間 | 2,041 ms |
コンパイル使用メモリ | 199,756 KB |
最終ジャッジ日時 | 2025-01-28 12:37:28 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() using ll = long long; int main() { int N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i]; sort(ALL(A)); const ll INF = 1LL << 60; ll t = INF, mx = -INF; int z = 0; for (int i = 0; i < N-1; i++) { if(A[i] == 0) z++; else { t = min(t, A[i+1] - A[i]); mx = max(mx, A[i+1] - A[i]); } } if(t == INF) { cout << "Yes" << endl; return 0; } if(t == 0) { if(mx != 0) cout << "No" << endl; else cout << "Yes" << endl; return 0; } bool ans = true; for (int i = 0; i < N-1; i++) { if(A[i] == 0) continue; ll x = A[i+1] - A[i]; if(x == t) continue; if(x % t) ans = false; z -= x / t -1; if(z < 0) ans = false; } cout << (ans ? "Yes" : "No") << endl; return 0; }