結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2024-07-28 01:37:00 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 665 bytes |
| コンパイル時間 | 1,355 ms |
| コンパイル使用メモリ | 95,196 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-28 01:37:03 |
| 合計ジャッジ時間 | 3,242 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin>>t;
vector<int> dp(t+1,0);
int n;
cin>>n;
vector<int> c(n),v(n);
for(int i = 0;i<n;i++) cin>>c[i];
for(int i = 0;i<n;i++) cin>>v[i];
for(int i = 0;i<n;i++){
while(v[i]>0){
for(int j = t;j>=0;j--){
if(j-c[i]<0) continue;
dp[j] = max(dp[j],dp[j-c[i]]+v[i]);
}
v[i] /= 2;
}
}
int mx = 0;
for(int i = 0;i<=t;i++) mx = max(mx,dp[i]);
cout<<mx<<endl;
}
momoyuu