Submission #634590

#TimeUsernameProblemLanguageResultExecution timeMemory
634590PixelCatTeam Contest (JOI22_team)C++14
73 / 100
473 ms773232 KiB
#include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define eb emplace_back #define int LL using namespace std; using LL = long long; using pii = pair<int, int>; inline void chmax(int &l, const int &r) { l = max(l, r); } inline void chmin(int &l, const int &r) { l = min(l, r); } struct Owo { int x, y, z; }; void solve1(int n) { vector<Owo> v(n); for(auto &i:v) { cin >> i.x >> i.y >> i.z; } sort(all(v), [](const auto &a, const auto &b) { return a.z < b.z; }); int ans = -1; For(r, 2, n - 1) { sort(v.begin(), v.begin() + r, [](const auto &a, const auto &b) { return a.y < b.y; }); int mxx = -1e18; int tmp = -1e18; For(m, 0, r - 1) { if(v[m].z == v[r].z) continue; if(v[m].y > v[r].y && mxx > max(v[m].x, v[r].x)) { ans = max(ans, v[m].y + v[r].z + mxx); } tmp = max(tmp, v[m].x); if(v[m + 1].y != v[m].y) mxx = tmp; } } cout << ans << "\n"; } const int MAX = 4010; int oaox[MAX][MAX]; int oaoy[MAX][MAX]; int oaoz[MAX][MAX]; void solve2(int n) { vector<Owo> v(n); For(i, 0, MAX - 1) For(j, 0, MAX - 1) { oaox[i][j] = 0; oaoz[i][j] = oaoy[i][j] = 1e18; } for(auto &i:v) { cin >> i.x >> i.y >> i.z; chmin(oaoy[i.y][i.z + 1], i.x); chmin(oaoz[i.y + 1][i.z], i.x); chmax(oaox[i.y][i.z], i.x); } int ans = -1; For(i, 1, MAX - 1) For(j, 1, MAX - 1) { chmax(oaox[i][j], max(oaox[i - 1][j], oaox[i][j - 1])); chmin(oaoy[i][j], oaoy[i][j - 1]); chmin(oaoz[i][j], oaoz[i - 1][j]); if(oaox[i - 1][j - 1] > max(oaoy[i][j], oaoz[i][j])) { chmax(ans, oaox[i - 1][j - 1] + i + j); } } cout << ans << "\n"; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); // OAO int n; cin >> n; if(n <= 4000) solve1(n); else solve2(n); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...