結果

問題 No.37 遊園地のアトラクション
ユーザー data9824data9824
提出日時 2015-06-15 23:51:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,101 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 66,208 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 02:26:00
合計ジャッジ時間 1,791 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int t, n;
	cin >> t >> n;
	vector<int> c(1 + n);
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
	}
	vector<int> v(1 + n);
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
	}
	// [until ?-th atraction][time]
	vector<vector<int> > satisfaction(n + 1, vector<int>(t + 1));
	fill(satisfaction[0].begin(), satisfaction[0].end(), 0);
	for (int i = 1; i <= n; ++i) {
		for (int k = 0; k <= t; ++k) {
			int maxSatisfaction = 0;
			int ithAttractionSatisfaction = 0;
			int ithAttractionSatisfactionDelta = v[i];
			for (int ithAttractionCount = 0;
				ithAttractionSatisfactionDelta > 0;
				++ithAttractionCount) {
				ithAttractionSatisfaction += ithAttractionSatisfactionDelta;
				if (k - c[i] * ithAttractionCount >= 0) {
					maxSatisfaction = max(maxSatisfaction,
						satisfaction[i - 1][k - c[i] * ithAttractionCount]
						+ ithAttractionSatisfaction);
				}
				ithAttractionSatisfactionDelta /= 2;
			}
			satisfaction[i][k] = maxSatisfaction;
		}
	}
	cout << satisfaction[n][t] << endl;
	return 0;
}
0