結果

問題 No.2693 Sword
ユーザー addnineaddnine
提出日時 2024-03-22 21:40:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 203,944 KB
実行使用メモリ 11,500 KB
最終ジャッジ日時 2024-03-22 21:40:05
合計ジャッジ時間 3,458 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 7 ms
10,420 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 4 ms
6,792 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 6 ms
9,960 KB
testcase_16 AC 6 ms
9,700 KB
testcase_17 AC 7 ms
10,304 KB
testcase_18 AC 4 ms
7,028 KB
testcase_19 AC 5 ms
7,316 KB
testcase_20 AC 6 ms
6,912 KB
testcase_21 AC 7 ms
7,680 KB
testcase_22 AC 6 ms
10,112 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll MX = 1e18;
ll dp[1010][1010];

int main() {
    ll N, P, K; cin >> N >> P >> K;
    vector<ll> T(N), B(N);
    for (int i = 0; i < N; i++) cin >> T[i] >> B[i];
    dp[0][0] = P;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= K; j++) {
            ll nxt = (T[i] == 1 ? dp[i][j] + B[i] : dp[i][j] * 2);
            dp[i+1][j+1] = max(dp[i][j+1], nxt);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << (dp[N][K] > MX ? -1 : dp[N][K]) << endl;
}
0