結果

問題 No.37 遊園地のアトラクション
ユーザー たこしたこし
提出日時 2014-11-04 11:06:14
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,207 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 87,864 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-29 00:30:17
合計ジャッジ時間 18,802 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

#define INF 100000000
#define EPS 1e-9

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define MAX_T 10000
#define MAX_N 15
int T, N;
int c[MAX_N];
int v[MAX_N];

int dp[MAX_N+1][MAX_T + 1];

int les(int s, int m){
	if (m == 0)
		return 0;
	int ans = s / (pow(2, m - 1)) + les(s, m-1);
	return ans;
}

int main() {

	cin >> T;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> c[i];
	}
	for (int i = 0; i < N; i++){
		cin >> v[i];
	}

	int ans = 0;

	for (int i = 0; i < N; i++){
		for (int j = 0; j <= T; j++){
			for (int m = 0; j - m*c[i] >= 0; m++){
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - m*c[i]] + les(v[i], m));
				ans = max(ans, dp[i + 1][j]);
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}
0