結果
| 問題 |
No.783 門松計画
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2019-01-11 22:48:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,319 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 87,288 KB |
| 実行使用メモリ | 53,376 KB |
| 最終ジャッジ日時 | 2024-11-30 13:22:48 |
| 合計ジャッジ時間 | 2,436 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 5 |
ソースコード
#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;
}
ats5515