結果

問題 No.868 ハイパー部分和問題
ユーザー kenken714kenken714
提出日時 2019-08-16 22:50:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 90,224 KB
実行使用メモリ 68,172 KB
最終ジャッジ日時 2023-10-24 02:32:29
合計ジャッジ時間 10,483 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,896 KB
testcase_01 AC 37 ms
4,948 KB
testcase_02 AC 409 ms
9,856 KB
testcase_03 AC 7 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

bool dp[254000000];

ll n, k, t[15000];
set<ll> s;
int main() {
	s.insert(0);
	cin >> n >> k;
	REP(i, n) {
		ll a;
		cin >> a;
		t[i] = a;
		set<ll> nexts = s;
		for (auto& i : s) {
			nexts.insert(i + a);
		}
		s = nexts;
	}
	for (auto& i : s)
	{
		dp[i] = true;
		//cout << i << " a" << endl;
	}
	ll q;
	cin >> q;
	REP(i, q) {
		ll x, a;
		cin >> x >> a;
		x--;
		k += t[x] - a;
		t[x] = a;
		if (0 <= k and k < 254000000) {
			if (dp[k]) {
				cout << 1 << endl;
				continue;
			}
		}
		cout << 0 << endl;
	}
}
	
0