結果

問題 No.37 遊園地のアトラクション
ユーザー pekempeypekempey
提出日時 2015-08-20 10:29:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 3,102 ms
コンパイル使用メモリ 144,548 KB
実行使用メモリ 5,300 KB
最終ジャッジ日時 2023-09-25 13:46:48
合計ジャッジ時間 3,935 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,064 KB
testcase_01 AC 3 ms
5,072 KB
testcase_02 AC 4 ms
5,072 KB
testcase_03 AC 4 ms
5,188 KB
testcase_04 AC 3 ms
5,032 KB
testcase_05 AC 4 ms
5,076 KB
testcase_06 AC 3 ms
5,072 KB
testcase_07 AC 5 ms
5,068 KB
testcase_08 AC 3 ms
5,104 KB
testcase_09 AC 3 ms
5,016 KB
testcase_10 AC 5 ms
5,212 KB
testcase_11 AC 4 ms
5,024 KB
testcase_12 AC 3 ms
5,020 KB
testcase_13 AC 4 ms
5,028 KB
testcase_14 AC 4 ms
5,128 KB
testcase_15 WA -
testcase_16 AC 4 ms
5,204 KB
testcase_17 AC 4 ms
5,276 KB
testcase_18 AC 5 ms
5,300 KB
testcase_19 AC 3 ms
5,076 KB
testcase_20 AC 4 ms
5,188 KB
testcase_21 AC 3 ms
5,188 KB
testcase_22 AC 6 ms
5,192 KB
testcase_23 AC 3 ms
5,048 KB
testcase_24 AC 3 ms
5,028 KB
testcase_25 AC 3 ms
5,060 KB
testcase_26 AC 3 ms
5,140 KB
testcase_27 WA -
testcase_28 AC 3 ms
5,064 KB
testcase_29 AC 3 ms
5,024 KB
testcase_30 AC 3 ms
5,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

int T, N;
int c[15], v[15];
int V[15][20];

int dp[22][20202];

int main() {
	cin >> T >> N;
	rep (i, N) cin >> c[i];
	rep (i, N) cin >> v[i];

	rep (i, N) {
		rep (j, 20) {
			V[i][j] = v[i] >> j;	
		}
	}

	rep (i, 22) rep (j, 20202) dp[i][j] = -inf;
	dp[0][0] = 0;

	rep (i, N) {
		rep (j, T) {
			int total = 0;
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			rep (k, 20) {
				total += V[i][k];
				dp[i + 1][j + c[i] * (k + 1)] = max(dp[i + 1][j + c[i] * (k + 1)], dp[i][j] + total);
			}
		}
	}

	int ans = -1;
	rep (j, T) {
		ans = max(ans, dp[N][j]);
	}
	cout << ans << endl;

	return 0;
}
0