結果
| 問題 |
No.1823 Tricolor Dango
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-20 17:33:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 871 bytes |
| コンパイル時間 | 4,249 ms |
| コンパイル使用メモリ | 253,032 KB |
| 最終ジャッジ日時 | 2025-02-20 08:12:28 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 24 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
int T, N, A[202020];
void solve() {
cin >> N;
priority_queue<int, vector<int>, less<int>> pq;
for (int i = 1; i <= N; i++) {
cin >> A[i];
pq.push(A[i]);
}
bool flag = true;
int d1, d2, d3;
while (!pq.empty()) {
if (!pq.empty()) {
d1 = pq.top(); pq.pop();
d1--;
} else {flag = false; break;}
if (!pq.empty()) {
d2 = pq.top(); pq.pop();
d2--;
} else {flag = false; break;}
if (!pq.empty()) {
d3 = pq.top(); pq.pop();
d3--;
} else {flag = false; break;}
if (d1 > 0) pq.push(d1);
if (d2 > 0) pq.push(d2);
if (d3 > 0) pq.push(d3);
}
if (flag) cout << "Yes" << endl;
else cout << "No" << endl;
}
int main() {
cin >> T;
while (T--) solve();
return 0;
}