結果
問題 |
No.2693 Sword
|
ユーザー |
|
提出日時 | 2024-03-22 23:49:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 417 bytes |
コンパイル時間 | 3,122 ms |
コンパイル使用メモリ | 245,576 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 12:47:37 |
合計ジャッジ時間 | 3,431 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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<ll> A(k+1,-1);A[0]=p; for(int i=1;i<=n;i++){ cin>>t>>b; for(int j=k-1;j>=0;j--){ if(A[j]>=1){ x=A[j]; if(t==1)x=min(x+b,INF+1); if(t==2)x=min(x*2,INF+1); A[j+1]=max(A[j+1],x); } } } cout<<(A[k]==INF+1?-1:A[k]); }