結果
| 問題 |
No.1045 直方体大学
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2020-05-01 22:46:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 625 ms / 2,000 ms |
| コード長 | 1,125 bytes |
| コンパイル時間 | 966 ms |
| コンパイル使用メモリ | 82,668 KB |
| 最終ジャッジ日時 | 2025-01-10 05:19:35 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using pint = pair<int, int>;
int main()
{
int N;
cin >> N;
vector<pint> xy(N * 3);
vector<int> z(N * 3);
int j = 0;
for (int i = 0; i < N; i++)
{
int a, b, c;
cin >> a >> b >> c;
for (int d = 0; d < 3; d++)
{
z[j] = a, xy[j] = make_pair(min(b, c), max(b, c));
swap(a, b), swap(b, c), j++;
}
}
xy.emplace_back(1e8, 1e8);
vector<vector<int>> dp(N * 3 + 1, vector<int>(1 << N));
for (int S = 0; S < (1 << N); S++)
{
for (int i = 0; i < N * 3 + 1; i++)
{
for (int j = 0; j < N * 3; j++) if (!((S >> (j / 3)) & 1))
{
if (xy[i].first < xy[j].first) continue;
if (xy[i].second < xy[j].second) continue;
dp[j][S + (1 << (j / 3))] = max(dp[j][S + (1 << (j / 3))], dp[i][S] + z[j]);
}
}
}
int ret = 0;
for (auto &vec : dp) ret = max(ret, *max_element(vec.begin(), vec.end()));
cout << ret << '\n';
}
hitonanode