結果

問題 No.1990 Candy Boxes
ユーザー 👑 NachiaNachia
提出日時 2022-06-24 22:09:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,048 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 81,108 KB
実行使用メモリ 5,420 KB
最終ジャッジ日時 2023-08-12 23:06:17
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge11 / judge7
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 15 ms
4,380 KB
testcase_13 AC 16 ms
4,424 KB
testcase_14 AC 11 ms
4,384 KB
testcase_15 AC 11 ms
4,624 KB
testcase_16 AC 12 ms
4,560 KB
testcase_17 AC 13 ms
4,880 KB
testcase_18 AC 14 ms
4,836 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 16 ms
4,384 KB
testcase_23 AC 20 ms
4,572 KB
testcase_24 AC 19 ms
4,564 KB
testcase_25 AC 27 ms
5,360 KB
testcase_26 AC 14 ms
5,144 KB
testcase_27 AC 15 ms
5,096 KB
testcase_28 AC 16 ms
5,356 KB
testcase_29 AC 15 ms
5,116 KB
testcase_30 AC 13 ms
4,824 KB
testcase_31 AC 16 ms
5,420 KB
testcase_32 AC 9 ms
4,388 KB
testcase_33 AC 13 ms
4,840 KB
testcase_34 AC 13 ms
4,496 KB
testcase_35 AC 18 ms
5,168 KB
testcase_36 AC 17 ms
5,224 KB
testcase_37 AC 15 ms
5,116 KB
testcase_38 AC 12 ms
4,576 KB
testcase_39 AC 14 ms
4,888 KB
testcase_40 AC 13 ms
5,152 KB
testcase_41 AC 13 ms
5,092 KB
testcase_42 AC 8 ms
4,384 KB
testcase_43 AC 11 ms
4,624 KB
testcase_44 AC 10 ms
4,572 KB
testcase_45 AC 11 ms
4,868 KB
testcase_46 AC 16 ms
4,628 KB
testcase_47 AC 19 ms
5,092 KB
testcase_48 AC 18 ms
4,940 KB
testcase_49 AC 2 ms
4,384 KB
testcase_50 AC 2 ms
4,384 KB
testcase_51 AC 2 ms
4,384 KB
testcase_52 AC 1 ms
4,384 KB
testcase_53 AC 1 ms
4,384 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 2 ms
4,384 KB
testcase_56 AC 1 ms
4,384 KB
testcase_57 AC 1 ms
4,384 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 2 ms
4,384 KB
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 2 ms
4,384 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 2 ms
4,380 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 19 ms
5,088 KB
testcase_66 AC 16 ms
4,840 KB
testcase_67 AC 17 ms
5,340 KB
testcase_68 WA -
testcase_69 AC 19 ms
5,148 KB
testcase_70 AC 19 ms
5,156 KB
testcase_71 AC 16 ms
4,676 KB
testcase_72 AC 21 ms
5,096 KB
testcase_73 AC 22 ms
5,116 KB
testcase_74 AC 14 ms
4,384 KB
testcase_75 AC 13 ms
4,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>


using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)


const i64 INF = 1001001001001001001;
using modint = atcoder::static_modint<998244353>;




int main(){
    int N; cin >> N;
    vector<i64> B(N+2, 0); rep(i,N) cin >> B[i+1];
    vector<int> A(N+2, 0);
    rep(i,N+1){
        if(B[i] % 2 == B[i+1] % 2) continue;
        bool match = (i%2) == (B[i]%2);
        A[i+1] = (match ? 1 : -1);
    }
    rep(i,N+1) A[i+1] += A[i];
    bool ans = true;
    rep(i,N+2) if(abs(A[i]) > B[i]) ans = false;
    rep(i,N+2) B[i] -= abs(A[i]);
    i64 t = 0;
    rep(i,N+2) t += B[i] * ((i%2==0) ? 1 : -1);
    if(t != 0) ans = false;
    cout << (ans ? "Yes" : "No") << '\n';
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0