結果

問題 No.868 ハイパー部分和問題
ユーザー leaf_1415leaf_1415
提出日時 2019-08-23 16:17:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 54,772 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 15:32:39
合計ジャッジ時間 15,969 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 621 ms
5,376 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 394 ms
5,376 KB
testcase_30 AC 393 ms
5,376 KB
testcase_31 AC 397 ms
5,376 KB
testcase_32 AC 611 ms
5,376 KB
testcase_33 AC 615 ms
5,376 KB
testcase_34 WA -
testcase_35 AC 1,435 ms
5,376 KB
testcase_36 AC 651 ms
5,376 KB
testcase_37 AC 651 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
		for(int i = a[x]; i <= k; i++){
			dp[i] += mod - dp[i-a[x]], dp[i] %= mod;
		}
		a[x] = v;
		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