結果
問題 | No.2693 Sword |
ユーザー |
|
提出日時 | 2024-03-22 22:10:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 626 bytes |
コンパイル時間 | 3,086 ms |
コンパイル使用メモリ | 249,180 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-30 11:38:48 |
合計ジャッジ時間 | 3,882 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 9 |
ソースコード
#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;for(int j=k-1;j>=0;j--){if(A[i-1][j]>=0){A[i][j]=max(A[i][j],A[i-1][j]);x=A[i-1][j];if(t==1){if(INF-x>b)A[i][j+1]=max(x+b,A[i][j+1]);else {cout<<-1;return 0;}}else if(t==2){if(INF/2>x)A[i][j+1]=max(x*2,A[i][j+1]);else {cout<<-1;return 0;}}}}}cout<<*max_element(A[n].begin(),A[n].end());}