結果

問題 No.37 遊園地のアトラクション
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-09 23:35:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 62,104 KB
実行使用メモリ 4,716 KB
最終ジャッジ日時 2023-08-25 02:27:48
合計ジャッジ時間 1,958 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;


#define FOR(i,s,e) for(int i = (s);i <= (e);i++)

int T;
int N;
int c[20];
int v[20];

vector<int> Vs[20];

int dp[20][20000];

int dp_cou[20][20000];
int main()
{
	cin >> T;
	cin >> N;

	FOR(i,1,N)
	{
		cin >> c[i];
	}

	FOR(i,1,N)
	{
		cin >> v[i];
		while(v[i] > 0)
		{
			Vs[i].push_back(v[i]);
			v[i] /= 2;
		}
		Vs[i].push_back(0);
	}

	int result = 0;

	for(int i = 1;i <= N;i++)
	{
		for(int j = 0;j <= T;j++)
		{
			if(j >= 1)
			{
				dp[i][j] = max(dp[i][j],dp[i - 1][j]);
			}
			if(j + c[i] <= T && dp[i][j + c[i]] < dp[i][j] + Vs[i][dp_cou[i][j]])
			{
				dp[i][j + c[i]] = dp[i][j] + Vs[i][dp_cou[i][j]];
				dp_cou[i][j + c[i]] += min(dp_cou[i][j] + 1,(int)Vs[i].size() - 1);
			}
			result = max(result , dp[i][j]);
		}
	}


	cout << result << endl;
	return 0;
}
0