제출 #777022

#제출 시각아이디문제언어결과실행 시간메모리
777022aZvezdaTeam Contest (JOI22_team)C++14
100 / 100
287 ms21828 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll MAX_N = 2e5 + 10; ll n; pair<ll, ll> a[MAX_N], b[MAX_N], c[MAX_N]; pair<ll, pair<ll, ll> > p[MAX_N]; signed main() { cin >> n; for(ll i = 0; i < n; i ++) { cin >> p[i].first >> p[i].second.first >> p[i].second.second; a[i] = {p[i].first, i}; b[i] = {p[i].second.first, i}; c[i] = {p[i].second.second, i}; } sort(a, a + n); sort(b, b + n); sort(c, c + n); ll pa = n - 1, pb = n - 1, pc = n - 1; ll ans = -1; set<ll> st; while(true) { if(min({pa, pb, pc}) == -1) { break; } if(st.find(a[pa].second) != st.end()) { pa --; continue; } if(st.find(b[pb].second) != st.end()) { pb --; continue; } if(st.find(c[pc].second) != st.end()) { pc --; continue; } if(a[pa].second == b[pb].second || a[pa].second == c[pc].second) { st.insert(a[pa].second); pa --; continue; } if(b[pb].second == c[pc].second) { st.insert(b[pb].second); pb --; continue; } if(p[a[pa].second].second.first >= b[pb].first) { st.insert(a[pa].second); pa --; continue; } if(p[a[pa].second].second.second >= c[pc].first) { st.insert(a[pa].second); pa --; continue; } if(p[b[pb].second].first >= a[pa].first) { st.insert(b[pb].second); pb --; continue; } if(p[b[pb].second].second.second >= c[pc].first) { st.insert(b[pb].second); pb --; continue; } if(p[c[pc].second].first >= a[pa].first) { st.insert(c[pc].second); pc --; continue; } if(p[c[pc].second].second.first >= b[pb].first) { st.insert(c[pc].second); pc --; continue; } ans = max(ans, a[pa].first + b[pb].first + c[pc].first); break; } cout << ans << 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...