| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355518 | retarde | Team Contest (JOI22_team) | C++20 | 2092 ms | 10764 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define int long long
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
const int mod = 1e9 + 7;
const int inf = INTMAX_MAX;
const bool tc = false;
struct pt {
int x, y, z;
bool operator<(const pt & other) const {
if (x != other.x) return x < other.x;
if (y != other.y) return y < other.y;
else return z < other.z;
}
};
inline void solve() {
int n; cin >> n;
// pts[x] gives points
map<int, vector<pt>> pts_temp; for (int i = 0; i < n; i++) {
pt cur; cin >> cur.x >> cur.y >> cur.z;
pts_temp[cur.x].pb(cur);
}
vector<pair<int, vector<pt>>> pts;
for (auto &x : pts_temp) pts.pb(x);
int ans = -1;
map<int, vector<pt>> avail; // avail[y] gives z
for (auto &item : pts) {
int x = item.fi; vector<pt> s = item.se;
// cout << "Processing X: " << x << '\n';
for (auto &xp : s) {
// cout << "X max point: " << xp.x << " " << xp.y << " " << xp.z << '\n';
// process priors
int mxz = -1;
for (auto &item2 : avail) {
// lesser x
int y = item2.fi; vector<pt> s2 = item2.se;
// cout << "Processing Y: " << y << '\n';
for (auto &yp : s2) {
// cout << "Point with lower X has: " << yp.x << " " << yp.y << " " << yp.z << '\n';
// int z = yp.z;
if (mxz > max(yp.z, xp.z) && yp.y > xp.y) {
// this state is usable
ans = max(ans, x + y + mxz);
}
}
// update mxz
for (auto &p : s2) {
mxz = max(mxz, p.z);
}
}
}
// cout << '\n';
// add
// cout << "Adding:\n";
for (auto &p : s) {
// these
avail[p.y].pb(p);
// cout << p.x << " " << p.y << " " << p.z << '\n';
}
// cout << '\n';
}
cout << ans << '\n';
}
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
signed main() {
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
//setIO();
int t = 1;
if (tc) {
cin >> t;
}
while (t--) {
solve();
}
}Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
