結果
問題 |
No.1045 直方体大学
|
ユーザー |
![]() |
提出日時 | 2020-05-01 23:16:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,639 bytes |
コンパイル時間 | 3,846 ms |
コンパイル使用メモリ | 230,668 KB |
最終ジャッジ日時 | 2025-01-10 05:31:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 TLE * 10 |
ソースコード
#pragma GCC optimize("Ofast") #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, bit_max = 1; REP(i, 0, N) { bit_max *= 3; cin >> x >> y >> z; box.emplace_back(x, y, z); } 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; dp1[100000000] = 0; sort(box2.begin(), box2.end(), greater<tuple<ll, ll, ll>>()); REP(i, 0, N) { tie(x, y, z) = box2[i]; for (auto p: dp1) { if (p.first >= y) dp2[y] = max(dp2[y], p.second + z); dp2[p.first] = max(dp2[p.first], p.second); } swap(dp1, dp2); } for (auto p: dp1) ans = max(ans, p.second); } cout << ans << endl; }