結果

問題 No.868 ハイパー部分和問題
ユーザー lam6er
提出日時 2025-03-20 20:34:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 714 bytes
コンパイル時間 1,929 ms
コンパイル使用メモリ 195,496 KB
実行使用メモリ 10,652 KB
最終ジャッジ日時 2025-03-20 20:36:17
合計ジャッジ時間 13,756 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 29 TLE * 1 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int Q;
    cin >> Q;

    while (Q--) {
        int x, v;
        cin >> x >> v;
        A[x - 1] = v;  // Update the array

        bitset<15001> dp;  // 0..15000
        dp[0] = 1;
        bool found = false;
        for (int a : A) {
            if (a == 0) continue;  // 0 cannot contribute to the sum
            dp |= dp << a;
            if (dp.test(K)) {  // Check if K is reachable now
                found = true;
                break;
            }
        }
        cout << (found ? 1 : 0) << '\n';
    }
    return 0;
}
0