結果

問題 No.2693 Sword
ユーザー takooo
提出日時 2024-03-22 23:33:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 3,144 ms
コンパイル使用メモリ 249,356 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-09-30 12:44:34
合計ジャッジ時間 4,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=0;j<k;j++){
      if(A[i-1][j]>=0){
        A[i][j]=max(A[i-1][j],A[i][j]);
        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]);
}
0