結果

問題 No.2693 Sword
ユーザー ttkkggwwttkkggww
提出日時 2024-03-22 23:40:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 4,623 ms
コンパイル使用メモリ 265,900 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-03-22 23:40:44
合計ジャッジ時間 5,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
ll N,P,K;
vector<ll> T,B;
using Pll = pair<ll,ll>;

ll next_P(ll P,ll T,ll B){
	if(T == 1) return min(P + B,1000'000'000'000'000'001ll);
	return min(P *2,1000'000'000'000'000'001ll);
}

void solve(){
	vector<vector<ll>> dp(N+1,vector<ll>(K+1,-1));
	dp[0][0] = P;
	for(ll i = 0;i<N;i++){
		for(ll j = 0;j<=K;j++){
			if(dp[i][j] == -1) continue;
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(j+1<=K)
			dp[i+1][j+1] = max(dp[i+1][j+1],next_P(dp[i][j],T[i],B[i]));
		}
	}
	ll ans = dp[N][K];
	if(ans>1'000'000'000'000'000'000) ans = -1;
	cout << ans << endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> N >> P >> K;
	T.resize(N);
	B.resize(N);
	for(ll i=0;i<N;i++){
		cin >> T[i] >> B[i];
	}
	solve();
}
0