結果

問題 No.2693 Sword
ユーザー umezoumezo
提出日時 2024-03-22 21:58:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 3,024 ms
コンパイル使用メモリ 247,736 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-03-22 21:58:27
合計ジャッジ時間 3,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 1 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 9 ms
9,088 KB
testcase_10 AC 3 ms
6,548 KB
testcase_11 AC 5 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 4 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 7 ms
7,552 KB
testcase_16 AC 8 ms
8,320 KB
testcase_17 AC 10 ms
9,600 KB
testcase_18 AC 5 ms
6,548 KB
testcase_19 AC 6 ms
7,040 KB
testcase_20 AC 5 ms
6,784 KB
testcase_21 AC 6 ms
7,552 KB
testcase_22 AC 7 ms
7,808 KB
testcase_23 AC 4 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
testcase_27 AC 2 ms
6,548 KB
testcase_28 AC 2 ms
6,548 KB
testcase_29 AC 2 ms
6,548 KB
testcase_30 AC 2 ms
6,548 KB
testcase_31 AC 2 ms
6,548 KB
testcase_32 AC 13 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const ll INF=1000000000000000001;
ll dp[1010][1010];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,p,k;
  cin>>n>>p>>k;
  vector<ll> T(n),B(n);
  rep(i,n) cin>>T[i]>>B[i];
  
  dp[0][k]=p;
  rep(i,n){
    rep(j,k+1){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j==0) continue;
      if(T[i]==1) dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+B[i]);
      else dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]*2);
      if(dp[i+1][j-1]>1000000000000000000) dp[i+1][j-1]=INF;
    }
  }
  if(dp[n][0]==INF) cout<<-1<<endl;
  else cout<<dp[n][0]<<endl;
  
  return 0;
}
0