結果

問題 No.2693 Sword
ユーザー soldraysoldray
提出日時 2024-03-26 21:59:18
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 872 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 159,692 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-26 21:59:24
合計ジャッジ時間 5,344 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 RE -
testcase_05 AC 2 ms
6,548 KB
testcase_06 RE -
testcase_07 AC 2 ms
6,548 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 WA -
testcase_25 AC 1 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
testcase_27 AC 1 ms
6,548 KB
testcase_28 AC 2 ms
6,548 KB
testcase_29 AC 1 ms
6,548 KB
testcase_30 AC 2 ms
6,548 KB
testcase_31 RE -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

#define yn(pope) (pope ? "Yes" : "No")

#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rrep(i, n, m) for (int i = (n); i > m; i--)

#define IINF (1 << 30)
#define INF (1ll << 60)

#define all(v) v.begin(), v.end()

int main() {
  int N, K;
  i64 P;
  cin >> N >> P >> K;

  vector dp(K + 1, 0ll);

  dp[0] = P;

  rep(i, 0, N) {
    int t;
    i64 b;
    cin >> t >> b;

    vector cp = dp;

    if (t == 1) {
      rep(j, 0, K) { cp[i + 1] = max(dp[i + 1], dp[i] + b); }
    }

    if (t == 2) {
      rep(j, 0, K) { cp[i + 1] = max(dp[i + 1], dp[i] << 1); }
    }

    dp = cp;

    rep(j, 0, K + 1) {
      if (dp[i] >= 1000000000000000000ll) {
        dp[i] = 1000000000000000000ll;
      }
    }
  }

  cout << (dp[K] >= 1000000000000000000ll ? -1 : dp[K]) << endl;

  return 0;
}
0