Submission #629709

#TimeUsernameProblemLanguageResultExecution timeMemory
629709flappybirdTeam Contest (JOI22_team)C++14
100 / 100
444 ms27200 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define MAX 151010 #define MAXS 20 #define INF 1000000000000000001 #define bb ' ' #define ln '\n' #define Ln '\n' int A[MAX]; int B[MAX]; int C[MAX]; signed main() { ios::sync_with_stdio(false), cin.tie(0); int N; cin >> N; int i; set<pii> sa, sb, sc; int a, b, c; for (i = 1; i <= N; i++) cin >> A[i] >> B[i] >> C[i], sa.emplace(A[i], i), sb.emplace(B[i], i), sc.emplace(C[i], i); while (1) { if (sa.empty()) { cout << -1 << ln; return 0; } a = sa.rbegin()->second; b = sb.rbegin()->second; c = sc.rbegin()->second; i = 0; if (B[a] >= B[b] || C[a] >= C[c]) i = a; if (A[b] >= A[a] || C[b] >= C[c]) i = b; if (A[c] >= A[a] || B[c] >= B[b]) i = c; if (i) { sa.erase(pii(A[i], i)); sb.erase(pii(B[i], i)); sc.erase(pii(C[i], i)); continue; } cout << A[a] + B[b] + C[c] << ln; 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...