結果

問題 No.1990 Candy Boxes
ユーザー KudeKude
提出日時 2022-06-24 23:02:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,223 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 225,836 KB
実行使用メモリ 5,476 KB
最終ジャッジ日時 2023-08-12 23:09:51
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,508 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 14 ms
4,380 KB
testcase_14 AC 9 ms
4,512 KB
testcase_15 AC 10 ms
4,860 KB
testcase_16 AC 10 ms
4,536 KB
testcase_17 AC 11 ms
4,792 KB
testcase_18 AC 12 ms
4,952 KB
testcase_19 AC 14 ms
4,864 KB
testcase_20 AC 15 ms
4,884 KB
testcase_21 AC 16 ms
4,948 KB
testcase_22 AC 13 ms
4,380 KB
testcase_23 AC 17 ms
4,532 KB
testcase_24 AC 16 ms
4,564 KB
testcase_25 AC 22 ms
5,340 KB
testcase_26 AC 13 ms
5,120 KB
testcase_27 AC 13 ms
5,236 KB
testcase_28 AC 14 ms
5,432 KB
testcase_29 AC 15 ms
5,156 KB
testcase_30 AC 12 ms
4,876 KB
testcase_31 AC 14 ms
5,476 KB
testcase_32 AC 9 ms
4,380 KB
testcase_33 AC 12 ms
4,948 KB
testcase_34 AC 12 ms
4,500 KB
testcase_35 AC 15 ms
5,092 KB
testcase_36 AC 15 ms
4,808 KB
testcase_37 AC 15 ms
5,216 KB
testcase_38 AC 13 ms
4,680 KB
testcase_39 AC 12 ms
4,952 KB
testcase_40 AC 13 ms
5,164 KB
testcase_41 AC 13 ms
5,220 KB
testcase_42 AC 7 ms
4,380 KB
testcase_43 AC 9 ms
4,684 KB
testcase_44 AC 8 ms
4,684 KB
testcase_45 AC 9 ms
4,624 KB
testcase_46 AC 16 ms
4,776 KB
testcase_47 AC 17 ms
5,148 KB
testcase_48 AC 15 ms
4,948 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 2 ms
4,380 KB
testcase_64 AC 2 ms
4,376 KB
testcase_65 AC 18 ms
5,232 KB
testcase_66 AC 14 ms
4,804 KB
testcase_67 AC 15 ms
4,972 KB
testcase_68 AC 8 ms
4,416 KB
testcase_69 AC 16 ms
5,152 KB
testcase_70 AC 18 ms
5,088 KB
testcase_71 AC 15 ms
4,564 KB
testcase_72 AC 19 ms
5,120 KB
testcase_73 AC 19 ms
5,472 KB
testcase_74 AC 13 ms
4,508 KB
testcase_75 AC 10 ms
4,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

bool solve() {
  int n;
  cin >> n;
  VI b(n);
  rep(i, n) cin >> b[i];
  VI tb = b;
  VI cnt(n);
  rep(i, n - 1) cnt[i] = b[i], b[i+1] -= b[i];
  if (*min_element(all(cnt)) < 0 || b.back() != 0) return false;
  b = tb;
  int now = 0;
  rep(i, n) {
    if (b[i] & 1) {
      if (i % 2) now++;
      else now--;
    }
    if (abs(now) > cnt[i]) return false;
  }
  return now == 0;
}

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << (solve() ? "Yes\n" : "No\n");
}
0