Submission #1348618

#TimeUsernameProblemLanguageResultExecution timeMemory
1348618avighnaTeam Contest (JOI22_team)C++20
17 / 100
2096 ms2116 KiB
#include <bits/stdc++.h>

using namespace std;

struct triplet {
  int x, y, z;
  triplet() : x(0), y(0), z(0) {}
  auto operator<=>(const triplet &r) const = default;
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  int n;
  cin >> n;
  vector<triplet> a(n);
  for (auto &[x, y, z] : a) {
    cin >> x >> y >> z;
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  n = a.size();

  int ans = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        vector<int> v = {i, j, k};
        auto max_rest = [&](int idx) {
          triplet ans;
          for (int i = 0; i < 3; ++i) {
            if (v[i] == idx) {
              continue;
            }
            ans.x = max(ans.x, a[v[i]].x);
            ans.y = max(ans.y, a[v[i]].y);
            ans.z = max(ans.z, a[v[i]].z);
          }
          return ans;
        };
        int aa = *max_element(v.begin(), v.end(), [&](int i, int j) { return a[i].x < a[j].x; });
        int bb = *max_element(v.begin(), v.end(), [&](int i, int j) { return a[i].y < a[j].y; });
        int cc = *max_element(v.begin(), v.end(), [&](int i, int j) { return a[i].z < a[j].z; });
        if (aa == bb || bb == cc || aa == cc || max_rest(aa).x == a[aa].x || max_rest(bb).y == a[bb].y || max_rest(cc).z == a[cc].z) {
          continue;
        }
        ans = max(ans, a[aa].x + a[bb].y + a[cc].z);
      }
    }
  }

  cout << ans << '\n';
}
#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...