結果
問題 | No.1823 Tricolor Dango |
ユーザー |
|
提出日時 | 2022-03-04 19:45:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,002 bytes |
コンパイル時間 | 2,264 ms |
コンパイル使用メモリ | 200,216 KB |
最終ジャッジ日時 | 2025-01-28 04:37:51 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define SZ(a) int(size(a)) #define ALL(a) begin(a), end(a) #define RALL(a) rbegin(a), rend(a) using ll = long long; using i128 = __int128_t; using ld = long double; using pii = pair<int, int>; bool solve() { int n; cin >> n; vector<ll> a(n); for (auto &x : a) cin >> x; ll sum = accumulate(ALL(a), 0LL); if (sum % 3) return false; sort(RALL(a)); auto f = [&](ll d) { ll cnt = 0; for (int i = 2; i < n; i++) { cnt += max(a[i] - (a[1] - d - 1), 0LL); } return cnt >= d; }; ll l = -1, r = a[1]; while (l + 1 < r) { ll m = (l + r) / 2; if (f(m)) l = m; else r = m; } if (l == 0) return false; return 2 * (a[0] - l) <= sum - 3 * l; } int main() { ios::sync_with_stdio(0); cin.tie(0); int tcs = 1; cin >> tcs; for (int tc = 1; tc <= tcs; tc++) { cout << (solve() ? "Yes" : "No") << '\n'; } }