結果

問題 No.37 遊園地のアトラクション
ユーザー たこしたこし
提出日時 2014-11-04 11:36:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,441 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 89,528 KB
実行使用メモリ 11,716 KB
最終ジャッジ日時 2023-08-29 00:29:47
合計ジャッジ時間 1,956 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,216 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 3 ms
6,848 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,376 KB
testcase_07 WA -
testcase_08 AC 3 ms
5,988 KB
testcase_09 AC 2 ms
5,708 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
6,592 KB
testcase_13 AC 3 ms
6,912 KB
testcase_14 AC 3 ms
6,004 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
7,024 KB
testcase_18 WA -
testcase_19 AC 2 ms
5,664 KB
testcase_20 WA -
testcase_21 AC 3 ms
6,140 KB
testcase_22 WA -
testcase_23 AC 2 ms
5,556 KB
testcase_24 AC 2 ms
5,540 KB
testcase_25 AC 2 ms
5,604 KB
testcase_26 AC 2 ms
5,716 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 3 ms
7,788 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_T 10000
#define MAX_N 15
#define MAX_V 500

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

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

	int ans = 0;

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

	cout << ans << endl;

	return 0;
}
0