Submission #938413

#TimeUsernameProblemLanguageResultExecution timeMemory
938413RegulusTeam Contest (JOI22_team)C++17
0 / 100
1 ms2504 KiB
#define TEST #include <bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0); #ifdef TEST #define debug(x) cerr << #x << " = " << (x) << ' ' #define bug(x) cerr << (x) << ' ' #define endl cerr << '\n' #else #define debug(x) cout << "" #define bug(x) cout << "" #define endl cout << "" #endif #define all(v) (v).begin(), (v).end() #define SZ(v) (ll)(v).size() #define lowbit(x) (x)&-(x) #define pb emplace_back #define F first #define S second using namespace std; using ll = long long; using pll = pair<ll, ll>; const int N = 2e5+5; int x[N], y[N], z[N], cnt[N]; bool del[N]; priority_queue<pll> pq, pq2, pq3; int main(void) { IO int n, i; cin >> n; for (i=1; i <= n; ++i) { cin >> x[i] >> y[i] >> z[i]; pq.push({x[i], i}); pq2.push({y[i], i}); pq3.push({z[i], i}); } while (!pq.empty() && !pq2.empty() && !pq3.empty()) { while (!pq.empty() && del[pq.top().S]) pq.pop(); while (!pq2.empty() && del[pq2.top().S]) pq2.pop(); while (!pq3.empty() && del[pq3.top().S]) pq3.pop(); if (pq.empty() || pq2.empty() || pq3.empty()) break; int a = pq.top().S, b = pq2.top().S, c = pq3.top().S; ++cnt[a], ++cnt[b], ++cnt[c]; if (cnt[a] > 1) del[a] = 1; if (cnt[b] > 1) del[b] = 1; if (cnt[c] > 1) del[c] = 1; if (!del[a] && !del[b] && !del[c]) { cout << x[a] + y[b] + z[c] << '\n'; exit(0); } cnt[a] = cnt[b] = cnt[c] = 0; } cout << "-1\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...