結果

問題 No.868 ハイパー部分和問題
ユーザー leaf_1415leaf_1415
提出日時 2019-08-23 16:30:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 596 ms
コンパイル使用メモリ 52,972 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 17:22:46
合計ジャッジ時間 15,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 646 ms
4,376 KB
testcase_15 AC 644 ms
4,384 KB
testcase_16 AC 647 ms
4,380 KB
testcase_17 AC 644 ms
4,380 KB
testcase_18 AC 645 ms
4,384 KB
testcase_19 AC 380 ms
4,380 KB
testcase_20 AC 383 ms
4,380 KB
testcase_21 AC 382 ms
4,380 KB
testcase_22 AC 383 ms
4,380 KB
testcase_23 AC 382 ms
4,380 KB
testcase_24 AC 381 ms
4,376 KB
testcase_25 AC 384 ms
4,376 KB
testcase_26 AC 381 ms
4,380 KB
testcase_27 AC 381 ms
4,376 KB
testcase_28 AC 380 ms
4,376 KB
testcase_29 AC 409 ms
4,380 KB
testcase_30 AC 406 ms
4,380 KB
testcase_31 AC 410 ms
4,380 KB
testcase_32 AC 643 ms
4,380 KB
testcase_33 AC 644 ms
4,380 KB
testcase_34 AC 1,117 ms
4,380 KB
testcase_35 AC 1,113 ms
4,376 KB
testcase_36 AC 681 ms
4,380 KB
testcase_37 AC 682 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define llint long long
#define mod 998244353

using namespace std;

llint n, Q, k;
llint a[15005];
llint dp[15005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		if(a[i] == 0) continue;
		for(int j = k; j >= 0; j--){
			if(j >= a[i]) dp[j] += dp[j-a[i]], dp[j] %= mod;
		}
	}
	
	cin >> Q;
	llint x, v;
	for(int q = 0; q < Q; q++){
		cin >> x >> v;
		if(a[x]){
			for(int i = a[x]; i <= k; i++){
				dp[i] += mod - dp[i-a[x]], dp[i] %= mod;
			}
		}
		a[x] = v;
		if(a[x]){
			for(int i = k; i >= a[x]; i--){
				dp[i] += dp[i-a[x]], dp[i] %= mod;
			}
		}
		if(dp[k]) cout << 1 << "\n";
		else cout << 0 << "\n";
	}
	flush(cout);
	
	return 0;
}
0