結果
問題 |
No.868 ハイパー部分和問題
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:35:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 722 bytes |
コンパイル時間 | 3,688 ms |
コンパイル使用メモリ | 194,648 KB |
実行使用メモリ | 9,600 KB |
最終ジャッジ日時 | 2025-06-12 13:41:59 |
合計ジャッジ時間 | 15,207 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 29 TLE * 1 -- * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MAX_K = 15000; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K; cin >> N >> K; vector<int> A(N); for (int &a : A) cin >> a; int Q; cin >> Q; bitset<MAX_K + 1> dp; while (Q--) { int x, v; cin >> x >> v; x--; // Convert to 0-based index A[x] = v; dp.reset(); dp[0] = true; bool found = false; for (int a : A) { if (a == 0 || a > K) continue; dp |= dp << a; if (dp[K]) { found = true; break; } } cout << found << '\n'; } return 0; }