結果
問題 |
No.868 ハイパー部分和問題
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:50:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,119 bytes |
コンパイル時間 | 1,892 ms |
コンパイル使用メモリ | 195,212 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-06-12 18:50:46 |
合計ジャッジ時間 | 13,377 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 29 TLE * 1 -- * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K; cin >> N >> K; vector<int> A(N); long long sum = 0; for (int i = 0; i < N; ++i) { cin >> A[i]; sum += A[i]; } int Q; cin >> Q; while (Q--) { int x, v; cin >> x >> v; x--; // Update sum sum -= A[x]; sum += v; A[x] = v; if (sum < K) { cout << 0 << '\n'; continue; } bool found = false; for (int a : A) { if (a == K) { found = true; break; } } if (found) { cout << 1 << '\n'; continue; } bitset<15001> dp; dp[0] = 1; bool early = false; for (int a : A) { if (a == 0 || a > K) continue; dp |= dp << a; if (dp[K]) { early = true; break; } } cout << (early || dp[K]) << '\n'; } return 0; }