結果
| 問題 |
No.868 ハイパー部分和問題
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:48:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 714 bytes |
| コンパイル時間 | 1,709 ms |
| コンパイル使用メモリ | 196,228 KB |
| 実行使用メモリ | 10,528 KB |
| 最終ジャッジ日時 | 2025-03-20 18:49:31 |
| 合計ジャッジ時間 | 13,147 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | AC * 29 TLE * 1 -- * 8 |
ソースコード
#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;
}
lam6er