結果
| 問題 |
No.2693 Sword
|
| コンテスト | |
| ユーザー |
ManjushriMitra
|
| 提出日時 | 2024-12-28 16:22:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,494 bytes |
| コンパイル時間 | 3,295 ms |
| コンパイル使用メモリ | 251,048 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-28 16:23:03 |
| 合計ジャッジ時間 | 3,838 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 WA * 1 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<int(n); ++i)
#define repll(i,m,n) for(ll i=m; i<ll(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define fi first
#define se second
template<typename T> bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; }
template<typename T> bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; }
template<typename T> T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; }
template<typename T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
ll P;
cin >> N >> P >> K;
vector<int> T(N);
vector<ll> B(N);
rep(i, 0, N) cin >> T[i] >> B[i];
vector dp(N+1, vector<ll>(K+1, -1LL));
dp[0][0] = P;
const ll inf = 1000000000000000000LL;
rep(i, 0, N){
rep(j, 0, K+1){
if(dp[i][j] == -1LL) continue;
if(j != K){
if(T[i] == 1){
if(inf > dp[i][j] + B[i]) chmax(dp[i+1][j+1], dp[i][j] + B[i]);
else chmax(dp[i+1][j+1], inf);
}else{
if(inf / 2LL > dp[i][j]) chmax(dp[i+1][j+1], 2LL * dp[i][j]);
else chmax(dp[i+1][j+1], inf);
}
}
chmax(dp[i+1][j], dp[i][j]);
}
}
cout << (dp[N][K] == inf ? -1 : dp[N][K]) << endl;
return 0;
}
ManjushriMitra