結果
| 問題 |
No.2693 Sword
|
| コンテスト | |
| ユーザー |
kokosei
|
| 提出日時 | 2024-03-22 21:33:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 743 bytes |
| コンパイル時間 | 2,677 ms |
| コンパイル使用メモリ | 243,480 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 10:58:00 |
| 合計ジャッジ時間 | 3,450 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = (ll)1e18 + 1;
int N, K;
ll P, B[1010];
int T[1010];
ll dp[1010];
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> P >> K;
dp[0] = P;
for(int i = 0;i < N;i++){
int t, b; cin >> t >> b;
for(int j = K - 1;j >= 0;j--){
if(t == 1){
dp[j + 1] = min(inf, max(dp[j + 1], dp[j] + b));
}else{
if(inf / 2 >= dp[j]){
dp[j + 1] = max(dp[j + 1], dp[j] * 2);
}else{
dp[j + 1] = inf;
}
}
}
}
cout << (dp[K] == inf ? -1 : dp[K]) << endl;
return 0;
}
kokosei