Submission #713899

#TimeUsernameProblemLanguageResultExecution timeMemory
713899becaidoTeam Contest (JOI22_team)C++17
100 / 100
101 ms5776 KiB
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 1.5e5 + 5;

int n;
array<int, 3> a[SIZE];
pair<int, int> p[3][SIZE];
bool is[SIZE];

void solve() {
    cin >> n;
    FOR (i, 1, n) FOR (j, 0, 2) cin >> a[i][j];
    sort(a + 1, a + n + 1);
    FOR (j, 1, n) FOR (i, 0, 2) {
        p[i][j].F = a[j][i];
        p[i][j].S = j;
    }
    FOR (i, 0, 2) sort(p[i] + 1, p[i] + n + 1, greater<pair<int, int>>());
    for (int i[3] = {1, 1, 1};;) {
        FOR (j, 0, 2) while (i[j] <= n && is[p[j][i[j]].S]) i[j]++;
        if (*max_element(i, i + 3) > n) break;
        int x = p[0][i[0]].S, y = p[1][i[1]].S, z = p[2][i[2]].S;
        debug(x, y, z);
        if (a[x][1] >= a[y][1] || a[x][2] >= a[z][2]) {is[x] = 1; continue;}
        if (a[y][0] >= a[x][0] || a[y][2] >= a[z][2]) {is[y] = 1; continue;}
        if (a[z][0] >= a[x][0] || a[z][1] >= a[y][1]) {is[z] = 1; continue;}
        cout << a[x][0] + a[y][1] + a[z][2] << '\n';
        return;
    }
    cout << "-1\n";
}

int main() {
    Waimai;
    solve();
}

Compilation message (stderr)

team.cpp: In function 'void solve()':
team.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 7122
      |                    ^~~~
team.cpp:41:9: note: in expansion of macro 'debug'
   41 |         debug(x, y, z);
      |         ^~~~~
#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...