結果

問題 No.1823 Tricolor Dango
ユーザー yansi819yansi819
提出日時 2024-03-20 17:33:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 871 bytes
コンパイル時間 4,568 ms
コンパイル使用メモリ 264,536 KB
実行使用メモリ 13,352 KB
最終ジャッジ日時 2024-03-20 17:34:07
合計ジャッジ時間 9,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,352 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0