結果

問題 No.868 ハイパー部分和問題
ユーザー chocoruskchocorusk
提出日時 2019-08-17 01:20:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6,839 ms / 7,000 ms
コード長 1,297 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 101,716 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:05:28
合計ジャッジ時間 73,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 3,273 ms
4,348 KB
testcase_15 AC 3,265 ms
4,348 KB
testcase_16 AC 3,278 ms
4,348 KB
testcase_17 AC 3,253 ms
4,348 KB
testcase_18 AC 3,272 ms
4,348 KB
testcase_19 AC 2,181 ms
4,348 KB
testcase_20 AC 2,179 ms
4,348 KB
testcase_21 AC 2,191 ms
4,348 KB
testcase_22 AC 2,178 ms
4,348 KB
testcase_23 AC 2,177 ms
4,348 KB
testcase_24 AC 2,176 ms
4,348 KB
testcase_25 AC 2,199 ms
4,348 KB
testcase_26 AC 2,180 ms
4,348 KB
testcase_27 AC 2,179 ms
4,348 KB
testcase_28 AC 2,179 ms
4,348 KB
testcase_29 AC 1,614 ms
4,348 KB
testcase_30 AC 1,609 ms
4,348 KB
testcase_31 AC 1,627 ms
4,348 KB
testcase_32 AC 3,266 ms
4,348 KB
testcase_33 AC 3,259 ms
4,348 KB
testcase_34 AC 6,839 ms
4,348 KB
testcase_35 AC 6,814 ms
4,348 KB
testcase_36 AC 3,619 ms
4,348 KB
testcase_37 AC 3,622 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int MOD[3]={998244353, 924844033, 1004535809};
int main()
{
	int n, k; cin>>n>>k;
	int a[15010], a0[15010];
	for(int i=0; i<n; i++) cin>>a[i], a0[i]=a[i];
	int q; cin>>q;
	int ans[15010]={};
	int x[15010], v[15010];
	for(int i=0; i<q; i++){
		cin>>x[i]>>v[i]; x[i]--;
	}
	for(int t=0; t<3; t++){
		int dp[15010]={};
		dp[0]=1;
		for(int i=0; i<n; i++){
			a[i]=a0[i];
			if(a[i]==0) continue;
			for(int j=k-a[i]; j>=0; j--){
				(dp[j+a[i]]+=dp[j])%=MOD[t];
			}
		}
		for(int i=0; i<q; i++){
			if(a[x[i]]!=0){
				for(int j=0; j<=k-a[x[i]]; j++){
					(dp[j+a[x[i]]]+=(MOD[t]-dp[j]))%=MOD[t];
				}
			}
			a[x[i]]=v[i];
			if(a[x[i]]!=0){
				for(int j=k-a[x[i]]; j>=0; j--) (dp[j+a[x[i]]]+=dp[j])%=MOD[t];
			}
			if(dp[k]!=0) ans[i]=1;
		}
	}
	for(int i=0; i<q; i++) printf("%d\n", ans[i]);
	return 0;
}
0