結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2015-09-11 08:28:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 1,430 bytes |
| コンパイル時間 | 791 ms |
| コンパイル使用メモリ | 91,668 KB |
| 実行使用メモリ | 12,108 KB |
| 最終ジャッジ日時 | 2024-10-10 13:05:48 |
| 合計ジャッジ時間 | 1,761 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>
#include <tuple>
#include <unordered_map>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int T,N;
vector<int> C;
vector<int> V;
int dp[20][10010][11];
int memo(int pos, int sum, int cnt, int value){
if (pos == N){
return 0;
}
if (sum > T)return 0;
int &res = dp[pos][sum][cnt];
if (res >= 0){
return res;
}
res = 0;
if (value > 0 and sum + C[pos] <= T){
res = max(res, memo(pos, sum + C[pos], cnt + 1, value / 2) + value);
}
res = max(res, memo(pos + 1, sum, 0, V[pos + 1]));
return res;
}
int main(){
cin >> T;
cin >> N;
C.resize(N);
V.resize(N);
for (int i = 0; i < N; i++){
cin >> C[i];
}
C.push_back(-1);
for (int i = 0; i < N; i++){
cin >> V[i];
}
V.push_back(-1);
memset(dp, -1, sizeof(dp));
cout << memo(0, 0, 0, V[0]) << endl;
}
togatoga