Submission #1018651

#TimeUsernameProblemLanguageResultExecution timeMemory
1018651UnforgettableplTeam Contest (JOI22_team)C++17
100 / 100
78 ms18604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int,int>> xs; vector<pair<int,int>> ys; vector<pair<int,int>> zs; vector<int> x(n+1),y(n+1),z(n+1); for(int i=1;i<=n;i++){ cin >> x[i] >> y[i] >> z[i]; xs.emplace_back(x[i],i); ys.emplace_back(y[i],i); zs.emplace_back(z[i],i); } sort(xs.rbegin(),xs.rend()); sort(ys.rbegin(),ys.rend()); sort(zs.rbegin(),zs.rend()); vector<bool> used(n+1); auto itx = xs.begin(); auto ity = ys.begin(); auto itz = zs.begin(); for(int i=1;i<=3*n;i++){ if(itx==xs.end() or ity==ys.end() or itz==zs.end())break; auto maxx = itx->first; auto maxy = ity->first; auto maxz = itz->first; if(y[itx->second]>=maxy or z[itx->second]>=maxz){ itx++; continue; } if(x[ity->second]>=maxx or z[ity->second]>=maxz){ ity++; continue; } if(x[itz->second]>=maxx or y[itz->second]>=maxy){ itz++; continue; } cout << maxx+maxy+maxz << '\n'; return 0; } cout << "-1\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...