結果

問題 No.37 遊園地のアトラクション
ユーザー togari_takamototogari_takamoto
提出日時 2016-02-26 14:25:10
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 915 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 166,428 KB
実行使用メモリ 14,276 KB
最終ジャッジ日時 2023-10-23 20:16:59
合計ジャッジ時間 3,589 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,960 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
5,268 KB
testcase_03 AC 4 ms
6,012 KB
testcase_04 AC 2 ms
4,588 KB
testcase_05 AC 3 ms
5,252 KB
testcase_06 AC 3 ms
4,988 KB
testcase_07 AC 12 ms
11,368 KB
testcase_08 AC 3 ms
4,504 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 7 ms
9,680 KB
testcase_11 AC 9 ms
9,544 KB
testcase_12 AC 3 ms
5,204 KB
testcase_13 AC 3 ms
5,796 KB
testcase_14 AC 2 ms
4,656 KB
testcase_15 AC 2 ms
4,768 KB
testcase_16 AC 5 ms
6,952 KB
testcase_17 AC 5 ms
6,400 KB
testcase_18 AC 11 ms
10,996 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 4 ms
6,132 KB
testcase_21 AC 3 ms
4,612 KB
testcase_22 AC 15 ms
14,276 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 3 ms
4,932 KB
testcase_28 RE -
testcase_29 AC 3 ms
4,368 KB
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)

int main() {
	ll t, n;
	cin >> t >> n;
	vl _c(n); REP(i, n) cin >> _c[i];
	vl _v(n); REP(i, n) cin >> _v[i];
	
	vl c, v;
	REP(i, n) while(_v[i]>0){
		c.push_back(_c[i]);
		v.push_back(_v[i]);
		_v[i] /= 2;
	}

	vvl dp(t + 1, vl(v.size(), -1));
	dp[c[0]][0] = v[0]; dp[0][0] = 0;
	FOR(i, 0, v.size()-1) REP(j, t + 1) if(dp[j][i]!=-1){
		if (t >= j + c[i + 1]) dp[j + c[i + 1]][i + 1] = dp[j][i] + v[i + 1];
		dp[j][i + 1] = max(dp[j][i+1], dp[j][i]);
	}

	ll ans = 0;
	REP(i, t + 1) ans = max(ans, dp[i][v.size() - 1]);
	cout << ans << endl;
	return 0;
}
0