# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547760 | Pherokung | Team Contest (JOI22_team) | C++14 | 102 ms | 5652 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> pa;
int n,X[3][150005];
pa v[3][150005];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=0;j<=2;j++){
scanf("%d",&X[j][i]);
v[j][i] = {X[j][i],i};
}
for(int i=0;i<=2;i++) sort(v[i]+1, v[i]+n+1, greater<pa>());
int a = 1, b = 1, c = 1;
while(a <= n && b <= n && c <= n){
int pa = v[0][a].S, pb = v[1][b].S, pc = v[2][c].S;
if(X[1][pa] >= X[1][pb] || X[2][pa] >= X[2][pc]) {
a++;
continue;
}
if(X[0][pb] >= X[0][pa] || X[2][pb] >= X[2][pc]){
b++;
continue;
}
if(X[0][pc] >= X[0][pa] || X[1][pc] >= X[1][pb]){
c++;
continue;
}
break;
}
if(a <= n && b <= n && c <=n) printf("%d",v[0][a].F + v[1][b].F + v[2][c].F);
else printf("-1");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |