結果

問題 No.868 ハイパー部分和問題
ユーザー niuezniuez
提出日時 2019-08-17 10:15:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 170,552 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 23:57:21
合計ジャッジ時間 15,564 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 WA -
testcase_05 WA -
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 1 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,057 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 248 ms
4,348 KB
testcase_30 AC 248 ms
4,348 KB
testcase_31 AC 250 ms
4,348 KB
testcase_32 AC 467 ms
4,348 KB
testcase_33 AC 468 ms
4,348 KB
testcase_34 WA -
testcase_35 AC 915 ms
4,348 KB
testcase_36 AC 512 ms
4,348 KB
testcase_37 AC 510 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N + 1);
  rep(i,1,N + 1) cin >> A[i];
  i64 mod = (1ll << 55) + 55;
  vector<i64> dp(K + 1, 0);
  dp[0] = 1;

  auto fix = [mod](i64 m) {
    if(m < 0) return m + mod;
    if(m >= mod) return m - mod;
    return m;
  };

  rep(i,1,N + 1) {
    for(int j = K; j >= A[i]; j--) {
      dp[j] = fix(dp[j] + dp[j - A[i]]);
    }
  }

  i64 Q;
  cin >> Q;

  rep(q, 0, Q) {
    i64 x, v;
    cin >> x >> v;
    for(int j = A[x]; j <= K; j++) {
      dp[j] = fix(dp[j] - dp[j - A[x]]);
    }
    A[x] = v;
    for(int j = K; j >= A[x]; j--) {
      dp[j] = fix(dp[j] + dp[j - A[x]]);
    }
    cout << (dp[K] != 0) << endl;
  }
}
0