結果

問題 No.2693 Sword
ユーザー askr58
提出日時 2024-03-22 22:11:53
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 5,546 ms
コンパイル使用メモリ 310,376 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-09-30 11:41:12
合計ジャッジ時間 6,243 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
ll inf=1e18+1;
int main()
{
    int n,k;
    ll p;
    cin>>n>>p>>k;
    vector<int> t(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++)cin>>t[i]>>b[i];
    vector<vector<ll>> dp(n+1,vector<ll>(k+1));
    dp[0][0]=p;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            if(j==0)dp[i+1][j]=dp[i][j];
            else{
                
                
                dp[i+1][j]=min(inf,max(dp[i][j],(t[i]==1?dp[i][j-1]+b[i]:dp[i][j-1]*2)));
            }
        }
    }
    if(dp[n][k]==inf)cout<<-1<<endl;
    else cout<<dp[n][k]<<endl;
}
0