結果

問題 No.868 ハイパー部分和問題
ユーザー betrue12betrue12
提出日時 2019-08-17 00:31:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 749 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 169,716 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:15:11
合計ジャッジ時間 14,658 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 544 ms
4,348 KB
testcase_15 AC 544 ms
4,348 KB
testcase_16 AC 546 ms
4,348 KB
testcase_17 AC 542 ms
4,348 KB
testcase_18 AC 543 ms
4,348 KB
testcase_19 AC 377 ms
4,348 KB
testcase_20 AC 377 ms
4,348 KB
testcase_21 AC 379 ms
4,348 KB
testcase_22 AC 377 ms
4,348 KB
testcase_23 AC 377 ms
4,348 KB
testcase_24 AC 379 ms
4,348 KB
testcase_25 AC 380 ms
4,348 KB
testcase_26 AC 376 ms
4,348 KB
testcase_27 AC 377 ms
4,348 KB
testcase_28 AC 376 ms
4,348 KB
testcase_29 AC 286 ms
4,348 KB
testcase_30 AC 283 ms
4,348 KB
testcase_31 AC 287 ms
4,348 KB
testcase_32 AC 543 ms
4,348 KB
testcase_33 AC 541 ms
4,348 KB
testcase_34 AC 1,091 ms
4,348 KB
testcase_35 AC 1,091 ms
4,348 KB
testcase_36 AC 593 ms
4,348 KB
testcase_37 AC 595 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int64_t dp[15001] = {0};
    dp[0] = 1;
    for(int i=0; i<N; i++) if(A[i]) for(int j=K; j-A[i]>=0; j--) add(dp[j], dp[j-A[i]]);
    int Q;
    cin >> Q;
    while(Q--){
        int i, v;
        cin >> i >> v;
        i--;
        if(A[i]) for(int j=A[i]; j<=K; j++) add(dp[j], MOD - dp[j-A[i]]);
        A[i] = v;
        if(A[i]) for(int j=K; j-A[i]>=0; j--) add(dp[j], dp[j-A[i]]);
        cout << (dp[K] ? 1 : 0) << endl;
    }
    return 0;
}
0