結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 731 ms
4,376 KB
testcase_15 AC 726 ms
4,376 KB
testcase_16 AC 730 ms
4,380 KB
testcase_17 AC 726 ms
4,376 KB
testcase_18 AC 729 ms
4,380 KB
testcase_19 AC 381 ms
4,376 KB
testcase_20 AC 380 ms
4,376 KB
testcase_21 AC 385 ms
4,380 KB
testcase_22 AC 380 ms
4,380 KB
testcase_23 AC 381 ms
4,376 KB
testcase_24 AC 381 ms
4,380 KB
testcase_25 AC 383 ms
4,380 KB
testcase_26 AC 381 ms
4,380 KB
testcase_27 AC 382 ms
4,376 KB
testcase_28 AC 382 ms
4,376 KB
testcase_29 AC 490 ms
4,376 KB
testcase_30 AC 489 ms
4,376 KB
testcase_31 AC 498 ms
4,380 KB
testcase_32 AC 727 ms
4,380 KB
testcase_33 AC 726 ms
4,380 KB
testcase_34 AC 1,315 ms
4,376 KB
testcase_35 AC 1,310 ms
4,376 KB
testcase_36 AC 763 ms
4,380 KB
testcase_37 AC 764 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 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++){
		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