結果
| 問題 |
No.2693 Sword
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-22 22:45:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 768 bytes |
| コンパイル時間 | 1,988 ms |
| コンパイル使用メモリ | 194,684 KB |
| 最終ジャッジ日時 | 2025-02-20 12:14:36 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll MX = 1e18 + 1;
void solve() {
ll n, p, k;
cin >> n >> p >> k;
vector<ll> dp(k + 1, -1);
dp[0] = p;
rep(ni, n) {
ll t, b;
cin >> t >> b;
for (ll ki = k - 1; ki >= 0; ki--) {
if (dp[ki] == -1)
continue;
if (t == 1) {
dp[ki + 1] = min(max(dp[ki + 1], dp[ki] + b), MX);
} else {
dp[ki + 1] = min(max(dp[ki + 1], dp[ki] * 2), MX);
}
}
}
ll ans = dp[k];
if (ans == MX)
ans = -1;
cout << ans << '\n';
}
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
int T = 1;
for (int t = 0; t < T; t++) {
solve();
}
return 0;
}