結果
| 問題 |
No.1045 直方体大学
|
| コンテスト | |
| ユーザー |
ptotq
|
| 提出日時 | 2020-05-01 23:07:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,569 bytes |
| コンパイル時間 | 2,035 ms |
| コンパイル使用メモリ | 190,576 KB |
| 実行使用メモリ | 16,960 KB |
| 最終ジャッジ日時 | 2024-12-25 14:12:12 |
| 合計ジャッジ時間 | 33,083 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 WA * 3 TLE * 10 |
ソースコード
#include <bits/stdc++.h>
#define REP(i, start, end) for (int64_t i=start, i##Len=(end); i < i##Len; ++i)
#define REPR(i, start, end) for (int64_t i=start, i##Len=(end); i > i##Len; --i)
using ll = int64_t;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
ll N;
cin >> N;
vector<tuple<ll, ll, ll>> box;
ll x, y, z;
REP(i, 0, N) {
cin >> x >> y >> z;
box.emplace_back(x, y, z);
}
ll bit_max = 1;
REP(i, 0, N) bit_max *= 3;
ll ans = 0;
REP(bit, 0, bit_max) {
ll b = bit;
vector<tuple<ll, ll, ll>> box2;
REP(i, 0, N) {
tie(x, y, z) = box[i];
switch (b % 3) {
case 0:
box2.emplace_back(max(y, z), min(y, z), x);
break;
case 1:
box2.emplace_back(max(x, z), min(x, z), y);
break;
case 2:
box2.emplace_back(max(x, y), min(x, y), z);
break;
}
b /= 3;
}
unordered_map<ll, ll> dp1, dp2;
sort(box2.begin(), box2.end(), greater<tuple<ll, ll, ll>>());
REP(i, 0, N) {
dp1[100000000] = 0;
tie(x, y, z) = box2[i];
for (auto p: dp1) {
if (p.first >= y) dp2[y] = max(dp2[y], p.second + z);
}
swap(dp1, dp2);
}
for (auto p: dp1) ans = max(ans, p.second);
}
cout << ans << endl;
}
ptotq