結果

問題 No.2693 Sword
ユーザー 聪
提出日時 2024-03-23 08:20:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,335 bytes
コンパイル時間 1,157 ms
コンパイル使用メモリ 94,192 KB
実行使用メモリ 11,372 KB
最終ジャッジ日時 2024-03-23 08:20:24
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
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 5 ms
10,332 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
8,208 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 3 ms
8,224 KB
testcase_20 AC 4 ms
10,040 KB
testcase_21 AC 5 ms
10,308 KB
testcase_22 AC 4 ms
10,256 KB
testcase_23 AC 3 ms
8,024 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 WA -
testcase_26 AC 2 ms
6,676 KB
testcase_27 WA -
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 <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <queue>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <numeric>

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define REP(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define FOR(i,a,b) for(int (i) = a; (i) < (b); ++(i))

int t[1010];
ll b[1010];
ll f[1010][1010];

int main ()
{
    int n, k;
    ll p;
    cin >> n >> p >> k;
    REP(i,n) {
        cin >> t[i] >> b[i];
    }
    REP(i, n) {
        f[i][0] = p;
        if (i == 0) {
            if (t[0] == 1)
                f[i][1] = p + b[0];
            else
                f[i][1] = p * 2;
            continue;
        }
        FOR(j, 1, k+1) {
            f[i][j] = f[i-1][j];
            if (f[i-1][j-1] > 0) {
                if (t[i] == 1)
                    f[i][j] = max(f[i][j], f[i-1][j-1] + b[i]);
                else
                    f[i][j] = max(f[i][j], f[i-1][j-1] * 2);
            } else continue;
            f[i][j] = min(f[i][j], (ll)(1e18) + 1);
            //cout << i << " " << j << " " << f[i][j] << endl;
        }
    }
    ll ans = f[n-1][k];
    if (ans > 1e18) ans = -1;
    cout << ans << endl;
}
0