結果

問題 No.783 門松計画
ユーザー ats5515ats5515
提出日時 2019-01-11 22:48:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,319 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 83,104 KB
実行使用メモリ 53,592 KB
最終ジャッジ日時 2023-08-20 11:39:02
合計ジャッジ時間 2,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,548 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
5,544 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
5,460 KB
testcase_05 AC 2 ms
5,596 KB
testcase_06 AC 3 ms
5,392 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,380 KB
testcase_09 AC 2 ms
5,552 KB
testcase_10 AC 182 ms
53,420 KB
testcase_11 AC 259 ms
53,592 KB
testcase_12 AC 236 ms
53,424 KB
testcase_13 AC 15 ms
12,348 KB
testcase_14 AC 64 ms
31,664 KB
testcase_15 AC 19 ms
16,608 KB
testcase_16 AC 5 ms
7,116 KB
testcase_17 AC 14 ms
13,472 KB
testcase_18 WA -
testcase_19 AC 47 ms
28,812 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 28 ms
21,472 KB
testcase_25 AC 11 ms
11,972 KB
testcase_26 AC 22 ms
16,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int dp[51][51][51][51];
void amax(int &res, int &a, const int &b) {
	a = max(a, b);
	res = max(res, b);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, C;
	cin >> N >> C;
	vector<pair<int, int> > A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i].second;
	}
	sort(A.begin(), A.end());

	for (int j = 0; j < N; j++) {
		for (int k = 0; k < N; k++) {
			if (A[j].first != A[k].first && A[j].second + A[k].second <= C) {
				dp[2][j][k][A[j].second + A[k].second] = A[j].first + A[k].first;
			}
		}
	}
	int res = 0;

	for (int i = 2; i < C; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < N; x++) {
					if ((j - k) * (k - x) < 0 && A[j].first != A[x].first) {
						for (int w = 0; w + A[x].second <= C; w++) {
							amax(res, dp[i + 1][k][x][w + A[x].second], dp[i][j][k][w] + A[x].first);
						}
					}
				}
			}
		}
	}
	/*cerr << dp[2][1][3][6] << endl;
	cerr << dp[3][3][0][9] << endl;
	cerr << dp[4][0][1][10] << endl;*/
	cout << res << endl;
}
0