結果

問題 No.37 遊園地のアトラクション
ユーザー ttkkggww
提出日時 2022-03-30 04:09:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 743 bytes
コンパイル時間 4,049 ms
コンパイル使用メモリ 253,188 KB
最終ジャッジ日時 2025-01-28 13:19:01
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int t,n;
vector<int> c,v;
vector<int> dpv[20001];
int dp[20001];

void solve(){
	dpv[0] = v;
	for(int i = 1;i<10000;i++)dpv[i] = vector<int>(n);
	for(int i = 0;i<10000;i++){
		for(int j = 0;j<n;j++){
			if(dp[i+c[j]]< dp[i] + dpv[i][j]){
				auto nv = dpv[i];
				nv[j] = nv[j]/2;
				dp[i+c[j]] = dp[i] + dpv[i][j];
				dpv[i+c[j]] = nv;
			}
		}
	}
	int ans = 0;
	for(int i = 0 ;i<=t;i++){
		ans = max(dp[i],ans);
	}
	cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> t >> n;
	c = v = vector<int>(n);
	for(int i = 0;i<n;i++)cin >> c[i];
	for(int i = 0;i<n;i++)cin >> v[i];
	solve();
}
0