#include #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) using namespace std; using ll = long long; const int U = 1 << 14; int K; vector items[U * 2]; void add(int l, int r, int v) { l += U; r += U - 1; while (l <= r) { if ((l & 1) == 1) items[l++].push_back(v); if ((r & 1) == 0) items[r--].push_back(v); l >>= 1; r >>= 1; } } int ans[U]; void dfs(int k, bitset<15001> dp) { for (int x : items[k]) dp |= dp << x; if (k >= U) { k -= U; ans[k] = dp[K]; return; } dfs(k * 2 + 0, dp); dfs(k * 2 + 1, dp); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N >> K; vector A(N); rep(i, N) cin >> A[i]; vector prev(N, 0); int Q; cin >> Q; for (int i = 1; i <= Q; i++) { int x, v; cin >> x >> v; x--; add(prev[x], i, A[x]); A[x] = v; prev[x] = i; } rep(i, N) add(prev[i], U, A[i]); bitset<15001> dp; dp[0] = true; dfs(1, dp); rep(i, Q) cout << ans[i+1] << '\n'; }