結果

問題 No.37 遊園地のアトラクション
ユーザー たこしたこし
提出日時 2014-11-05 14:15:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,343 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 91,116 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-04-18 19:27:54
合計ジャッジ時間 1,926 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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_N 15
#define MAX_T 10000

int T, N;
int c[MAX_N], v[MAX_N];
int cc[MAX_N * 10], vv[MAX_N * 10];

int dp[MAX_N * 10][MAX_T];

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 v_count = 0;
	for (int i = 0; i < N; i++){
		int two = 0;
		while (v[i] >= (int)pow(2,two) ){
			vv[v_count] = (int)(v[i] / (int)pow(2, two));
			cc[v_count] = c[i];
			v_count++;
			two++;
		}
	}

	int ans = 0;
	for (int i = 0; i < v_count; i++){
		for (int j = 0; j <= T; j++){
			if (j - cc[i] >= 0)
				dp[i + 1][j] = max(dp[i][j], dp[i][j - cc[i]] + vv[i]);
			else
				dp[i + 1][j] = dp[i][j];
			ans = max(ans, dp[i + 1][j]);
		}
	}

	cout << ans << endl;

	return 0;
}
0