結果

問題 No.868 ハイパー部分和問題
ユーザー chocoruskchocorusk
提出日時 2019-08-17 01:02:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,073 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 101,536 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:33:23
合計ジャッジ時間 15,354 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 WA -
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 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 626 ms
4,348 KB
testcase_15 AC 621 ms
4,348 KB
testcase_16 AC 624 ms
4,348 KB
testcase_17 AC 622 ms
4,348 KB
testcase_18 AC 624 ms
4,348 KB
testcase_19 AC 428 ms
4,348 KB
testcase_20 AC 430 ms
4,348 KB
testcase_21 AC 433 ms
4,348 KB
testcase_22 AC 432 ms
4,348 KB
testcase_23 AC 430 ms
4,348 KB
testcase_24 AC 429 ms
4,348 KB
testcase_25 AC 432 ms
4,348 KB
testcase_26 AC 429 ms
4,348 KB
testcase_27 AC 431 ms
4,348 KB
testcase_28 AC 431 ms
4,348 KB
testcase_29 AC 325 ms
4,348 KB
testcase_30 AC 323 ms
4,348 KB
testcase_31 AC 327 ms
4,348 KB
testcase_32 AC 624 ms
4,348 KB
testcase_33 AC 623 ms
4,348 KB
testcase_34 AC 1,239 ms
4,348 KB
testcase_35 AC 1,236 ms
4,348 KB
testcase_36 AC 684 ms
4,348 KB
testcase_37 AC 686 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 1 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;
const int MOD=1e9+9;
int main()
{
	int n, k; cin>>n>>k;
	int a[15010];
	for(int i=0; i<n; i++) cin>>a[i];
	int dp[15010]={}; dp[0]=1;
	for(int i=0; i<n; i++){
      if(a[i]==0) continue;
		for(int j=k-a[i]; j>=0; j--){
			(dp[j+a[i]]+=dp[j])%=MOD;
		}
	}
	int q; cin>>q;
	for(int i=0; i<q; i++){
		int x, v; cin>>x>>v;
		x--;
      if(a[x]!=0){
		for(int j=0; j<=k-a[x]; j++){
			(dp[j+a[x]]+=(MOD-dp[j]))%=MOD;
		}
      }
		a[x]=v;
      if(a[x]!=0){
		for(int j=k-a[x]; j>=0; j--) (dp[j+a[x]]+=dp[j])%=MOD;
      }
		if(dp[k]!=0) printf("1\n");
		else printf("0\n");
	}
	return 0;
}
0