| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1370354 | pirmyratg | Team Contest (JOI22_team) | C++20 | 56 ms | 10716 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pll pair<ll, ll>
const int N = 2e5+7;
pll vS[N], vA[N], vI[N];
int p[N][2], ctr[3];
bool d[N][2];
int main(){
int n;
scanf("%d", &n);
vector<int> S(n+1), A(n+1), I(n+1);
for(int i = 1; i <= n; ++i){
scanf("%d%d%d", &S[i], &A[i], &I[i]);
vS[i]={S[i], i}; vA[i]={A[i], i}; vI[i]={I[i], i};
}
auto f1=[&](pll u, pll v){
if(u.ff!=v.ff)return u.ff>v.ff;
return p[u.ss][0]<p[v.ss][0];
};
auto f2=[&](pll u, pll v){
if(u.ff!=v.ff)return u.ff>v.ff;
return (ll)I[u.ss]>(ll)I[v.ss];
};
sort(vS+1, vS+n+1, greater<pll>());
sort(vA+1, vA+n+1, f2);
for(int i=1; i<=n; ++i)
p[vA[i].ss][0]=i;
sort(vI+1, vI+n+1, f1);
for(int i=1; i<=n; ++i)
p[vI[i].ss][1]=i;
ctr[0]=ctr[1]=ctr[2]=1;
for(int i=1; i<=n; ++i){
while(ctr[2]<=n && vS[ctr[2]].ff==vS[i].ff){
int id=vS[ctr[2]].ss;
d[p[id][0]][0]=d[p[id][1]][1]=1;
ctr[2]++;
}
while(1){
for(int j=0; j<2; ++j){
while(ctr[j]<=n && d[ctr[j]][j])
ctr[j]++;
if(ctr[j]>n){
puts("-1");
return 0;
}
}
if(vA[ctr[0]].ss!=vI[ctr[1]].ss)
break;
d[ctr[0]][0]=d[ctr[1]][1]=1;
}
if(vA[ctr[0]].ff>(ll)A[vS[i].ss] && vI[ctr[1]].ff>(ll)I[vS[i].ss]){
printf("%lld\n", (ll)vS[i].ff+vA[ctr[0]].ff+vI[ctr[1]].ff);
return 0;
}
}
return 0;
}Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
