結果
問題 | No.2693 Sword |
ユーザー |
|
提出日時 | 2024-03-23 00:20:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 488 bytes |
コンパイル時間 | 2,511 ms |
コンパイル使用メモリ | 251,640 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-30 12:49:04 |
合計ジャッジ時間 | 3,356 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;ll INF=1000000000000000000;int main(){ll n,p,k,t,b,x;cin>>n>>p>>k;vector A(n+1,vector<ll>(k+1,-1));A[0][0]=p;for(int i=1;i<=n;i++){cin>>t>>b;A[i]=A[i-1];for(int j=0;j<k;j++){if(A[i-1][j]>=0&&A[i-1][j]<=INF){x=A[i-1][j];if(t==1)A[i][j+1]=max(min(x+b,INF+1),A[i][j+1]);if(t==2)A[i][j+1]=max(min(x*2,INF+1),A[i][j+1]);}}}cout<<(A[n][k]==INF+1?-1:A[n][k]);}