結果

問題 No.868 ハイパー部分和問題
ユーザー chocoruskchocorusk
提出日時 2019-08-16 22:31:03
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,024 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 100,664 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 14:41:24
合計ジャッジ時間 8,510 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 1 ms
4,368 KB
testcase_14 AC 274 ms
4,368 KB
testcase_15 AC 271 ms
4,368 KB
testcase_16 AC 272 ms
4,368 KB
testcase_17 AC 271 ms
4,368 KB
testcase_18 AC 272 ms
4,368 KB
testcase_19 AC 193 ms
4,368 KB
testcase_20 AC 195 ms
4,368 KB
testcase_21 AC 195 ms
4,368 KB
testcase_22 AC 194 ms
4,368 KB
testcase_23 AC 195 ms
4,368 KB
testcase_24 AC 195 ms
4,368 KB
testcase_25 AC 196 ms
4,368 KB
testcase_26 AC 194 ms
4,368 KB
testcase_27 AC 195 ms
4,368 KB
testcase_28 AC 194 ms
4,368 KB
testcase_29 AC 153 ms
4,368 KB
testcase_30 AC 152 ms
4,368 KB
testcase_31 AC 153 ms
4,368 KB
testcase_32 AC 273 ms
4,368 KB
testcase_33 AC 276 ms
4,368 KB
testcase_34 AC 446 ms
4,368 KB
testcase_35 AC 444 ms
4,368 KB
testcase_36 AC 297 ms
4,368 KB
testcase_37 AC 298 ms
4,368 KB
testcase_38 AC 2 ms
4,368 KB
testcase_39 AC 1 ms
4,368 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 main()
{
	int n, k; cin>>n>>k;
	int a[15010];
	for(int i=0; i<n; i++) cin>>a[i];
	ll 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];
		}
	}
	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]]-=dp[j];
		}
      }
		a[x]=v;
      if(a[x]!=0){
		for(int j=k-a[x]; j>=0; j--) dp[j+a[x]]+=dp[j];
      }
		if(dp[k]!=0) printf("1\n");
		else printf("0\n");
	}
	return 0;
}
0