結果

問題 No.868 ハイパー部分和問題
ユーザー e869120e869120
提出日時 2019-08-16 23:16:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 65,024 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 05:14:26
合計ジャッジ時間 84,447 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 17 ms
4,348 KB
testcase_02 AC 30 ms
4,348 KB
testcase_03 AC 12 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 7 ms
4,348 KB
testcase_07 AC 7 ms
4,348 KB
testcase_08 AC 7 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 7 ms
4,348 KB
testcase_11 AC 7 ms
4,348 KB
testcase_12 AC 7 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3,842 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1,919 ms
4,348 KB
testcase_30 AC 1,908 ms
4,348 KB
testcase_31 AC 1,935 ms
4,348 KB
testcase_32 AC 3,827 ms
4,348 KB
testcase_33 AC 3,842 ms
4,348 KB
testcase_34 TLE -
testcase_35 TLE -
testcase_36 AC 4,269 ms
4,348 KB
testcase_37 AC 4,270 ms
4,348 KB
testcase_38 AC 4 ms
4,348 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

long long N, K, Q, A[15009], X[15009], V[15009];
long long dp[15009], mod = 1000000007;

int main() {
	cin >> N >> K; dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		for (int j = 15000; j >= A[i]; j--) {
			dp[j] += dp[j - A[i]];
			dp[j] %= mod;
		}
	}

	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> X[i] >> V[i];
		for (int j = A[X[i]]; j <= 15000; j++) {
			dp[j] -= dp[j - A[X[i]]];
			dp[j] = (dp[j] + mod) % mod;
		}
		A[X[i]] = V[i];
		for (int j = 15000; j >= V[i]; j--) {
			dp[j] += dp[j - V[i]];
			dp[j] %= mod;
		}
		if (dp[K] == 0) cout << "0" << endl;
		else cout << "1" << endl;
	}
	return 0;
}
0