Submission #1054954

#TimeUsernameProblemLanguageResultExecution timeMemory
1054954j_vdd16Team Contest (JOI22_team)C++17
55 / 100
2008 ms17216 KiB
#include <algorithm> #include <bitset> #include <cstdint> #include <cstring> #include <iostream> #include <limits.h> #include <math.h> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define int long long #define loop(X, N) for(int X = 0; X < (N); X++) #define all(V) V.begin(), V.end() #define rall(V) V.rbegin(), V.rend() using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vector<ii>> vvii; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; int getMax(int* data, int size) { bool isSame = false; int best = 0; for (int i = 1; i < size; i++) { if (data[i] > data[best]) { best = i; isSame = false; } else if (data[i] == data[best]) isSame = true; } if (isSame) return -1; return best; } struct Beaver { int x = 0, y = 0, z = 0; bool operator<(const Beaver& b) const { return x > b.x || (x == b.x && y > b.y) || (x == b.x && y == b.y && z > b.z); } bool operator==(const Beaver& b) const { return x == b.x && y == b.y && z == b.z; } }; bool compX(const Beaver& a, const Beaver& b) { return a.x > b.x; } bool compY(const Beaver& a, const Beaver& b) { return a.y > b.y || (a.y == b.y && a.z > b.z); } signed main() { int n; cin >> n; set<Beaver> beaverSet; vector<Beaver> beavers; loop(i, n) { int x, y, z; cin >> x >> y >> z; beaverSet.insert(Beaver{x, y, z}); } for (auto beaver : beaverSet) beavers.push_back(beaver); n = (int)beavers.size(); int bestScore = -1; int jStart = n - 1; for (int i = n - 1; i >= 0; i--) { const Beaver& beaver1 = beavers[i]; jStart = min(jStart, n - 1); while (jStart >= i && beavers[jStart].x < beavers[i].x) jStart--; jStart++; if (jStart >= n) continue; set<ii, greater<ii>> beaversLeftList; for (int j = jStart; j < n; j++) beaversLeftList.insert({ beavers[j].y, beavers[j].z }); vii beaversLeft; for (auto x : beaversLeftList) { beaversLeft.push_back(x); } int m = (int)beaversLeft.size(); vi sufMaxZ(m + 1); for (int j = m - 1; j >= 0; j--) sufMaxZ[j] = max(sufMaxZ[j + 1], beaversLeft[j].second); int kStart = 1; for (int j = 0; j < m; j++) { if (beaversLeft[j].first <= beaver1.y) continue; while (kStart < m && beaversLeft[j].first <= beaversLeft[kStart].first) kStart++; if (kStart == m) break; if (sufMaxZ[kStart] <= beaversLeft[j].second || sufMaxZ[kStart] <= beaver1.z) continue; int score = beaver1.x + beaversLeft[j].first + sufMaxZ[kStart]; bestScore = max(score, bestScore); } } std::cout << bestScore << endl; 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...