結果

問題 No.868 ハイパー部分和問題
ユーザー autumn-eelautumn-eel
提出日時 2019-08-17 11:42:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 167,200 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 00:05:27
合計ジャッジ時間 17,814 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 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 1 ms
4,348 KB
testcase_14 AC 624 ms
4,348 KB
testcase_15 AC 624 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 624 ms
4,348 KB
testcase_18 AC 623 ms
4,348 KB
testcase_19 AC 542 ms
4,348 KB
testcase_20 AC 541 ms
4,348 KB
testcase_21 AC 545 ms
4,348 KB
testcase_22 AC 541 ms
4,348 KB
testcase_23 AC 543 ms
4,348 KB
testcase_24 AC 545 ms
4,348 KB
testcase_25 AC 540 ms
4,348 KB
testcase_26 AC 540 ms
4,348 KB
testcase_27 AC 540 ms
4,348 KB
testcase_28 AC 542 ms
4,348 KB
testcase_29 AC 568 ms
4,348 KB
testcase_30 AC 566 ms
4,348 KB
testcase_31 AC 567 ms
4,348 KB
testcase_32 AC 623 ms
4,348 KB
testcase_33 AC 620 ms
4,348 KB
testcase_34 WA -
testcase_35 AC 832 ms
4,348 KB
testcase_36 AC 642 ms
4,348 KB
testcase_37 AC 642 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[20000];
double dp[20000];
double dp2[20000];

int main(){
	int n,K;cin>>n>>K;
	dp[0]=1;
	rep(i,n){
		scanf("%d",&a[i]);
		if(a[i]){
			for(int j=K;j>=a[i];j--){
				dp[j]+=dp[j-a[i]];
			}
		}
	}
	int q;scanf("%d",&q);
	rep(i,q){
		int x,v;scanf("%d%d",&x,&v);x--;
		for(int i=0;i<=K;i++){
			if(a[x]){
				if(i<a[x])dp2[i]=dp[i];
				else dp2[i]=dp[i]-dp2[i-a[x]];
			}
			else dp2[i]=dp[i];
		}
		a[x]=v;
		for(int i=0;i<=K;i++){
			if(a[x]){
				if(i<a[x])dp[i]=dp2[i];
				else dp[i]=dp2[i-a[x]]+dp2[i];
			}
			else dp[i]=dp2[i];
		}
		puts(dp[K]>0.5?"1":"0");
	}
}
0