#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long int ll;
ll n,z,t,i,j,x,y,a[1100000];
pair<ll,pair<ll,ll>> p[1100000];
map<pair<ll,pair<ll,ll>>,ll> m;
vector<pair<ll,ll>> u;
vector<pair<pair<ll,ll>,ll>> v[1100000];
set<pair<pair<ll,ll>,ll>> s;
int main()
{
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
scanf("%lld %lld %lld",&x,&y,&z);
if(m[{x,{y,z}}]==1)
continue;
m[{x,{y,z}}]=1;
t++;
p[t]={x,{y,z}};
}
z=0;
n=t;
sort(p+1,p+n+1);
for(i=1;i<=n;i++)
{
s.insert({p[i].second,i});
for(auto l=s.begin();l!=s.end();l++)
v[i+1].push_back((*l));
}
for(i=1;i<=n;i++)
{//printf("%lld",i);
t=0;
u.clear();
for(j=0;j<(i-1);j++)
{
if(p[v[i][j].second].first==p[i].first)
continue;
if(v[i][j].first.first>p[i].second.first||v[i][j].first.second>p[i].second.second)
{u.push_back(v[i][j].first); t++; }
}
for(j=0;j<t;j++)
{
if(j==0)
a[j]=u[j].second;
else
a[j]=max(a[j-1],u[j].second);
}
for(j=t-1;j>=1;j--)
{
if(u[j].second<a[j-1])
{
z=max(z,u[j].first+a[j-1]+p[i].first);
break;
}
}
}
if(z==0)
z=-1;
printf("%lld",z);
}
Compilation message
team.cpp: In function 'int main()':
team.cpp:19:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
19 | if(m[{x,{y,z}}]==1)
| ^~
team.cpp:21:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
21 | m[{x,{y,z}}]=1;
| ^
team.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
team.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%lld %lld %lld",&x,&y,&z);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
13 ms |
26068 KB |
Output is correct |
3 |
Correct |
13 ms |
26088 KB |
Output is correct |
4 |
Correct |
13 ms |
26144 KB |
Output is correct |
5 |
Correct |
13 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26140 KB |
Output is correct |
7 |
Correct |
13 ms |
26068 KB |
Output is correct |
8 |
Correct |
13 ms |
26140 KB |
Output is correct |
9 |
Correct |
13 ms |
26112 KB |
Output is correct |
10 |
Correct |
14 ms |
26108 KB |
Output is correct |
11 |
Correct |
14 ms |
26040 KB |
Output is correct |
12 |
Correct |
13 ms |
26136 KB |
Output is correct |
13 |
Correct |
16 ms |
26068 KB |
Output is correct |
14 |
Correct |
17 ms |
27680 KB |
Output is correct |
15 |
Incorrect |
14 ms |
27028 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
13 ms |
26068 KB |
Output is correct |
3 |
Correct |
13 ms |
26088 KB |
Output is correct |
4 |
Correct |
13 ms |
26144 KB |
Output is correct |
5 |
Correct |
13 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26140 KB |
Output is correct |
7 |
Correct |
13 ms |
26068 KB |
Output is correct |
8 |
Correct |
13 ms |
26140 KB |
Output is correct |
9 |
Correct |
13 ms |
26112 KB |
Output is correct |
10 |
Correct |
14 ms |
26108 KB |
Output is correct |
11 |
Correct |
14 ms |
26040 KB |
Output is correct |
12 |
Correct |
13 ms |
26136 KB |
Output is correct |
13 |
Correct |
16 ms |
26068 KB |
Output is correct |
14 |
Correct |
17 ms |
27680 KB |
Output is correct |
15 |
Incorrect |
14 ms |
27028 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
12 ms |
26084 KB |
Output is correct |
3 |
Correct |
12 ms |
26068 KB |
Output is correct |
4 |
Correct |
15 ms |
26068 KB |
Output is correct |
5 |
Correct |
16 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26244 KB |
Output is correct |
7 |
Correct |
16 ms |
26032 KB |
Output is correct |
8 |
Correct |
13 ms |
26068 KB |
Output is correct |
9 |
Correct |
15 ms |
26068 KB |
Output is correct |
10 |
Correct |
13 ms |
26140 KB |
Output is correct |
11 |
Correct |
48 ms |
26440 KB |
Output is correct |
12 |
Incorrect |
36 ms |
26316 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
12 ms |
26084 KB |
Output is correct |
3 |
Correct |
12 ms |
26068 KB |
Output is correct |
4 |
Correct |
15 ms |
26068 KB |
Output is correct |
5 |
Correct |
16 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26244 KB |
Output is correct |
7 |
Correct |
16 ms |
26032 KB |
Output is correct |
8 |
Correct |
13 ms |
26068 KB |
Output is correct |
9 |
Correct |
15 ms |
26068 KB |
Output is correct |
10 |
Correct |
13 ms |
26140 KB |
Output is correct |
11 |
Correct |
48 ms |
26440 KB |
Output is correct |
12 |
Incorrect |
36 ms |
26316 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
12 ms |
26084 KB |
Output is correct |
3 |
Correct |
12 ms |
26068 KB |
Output is correct |
4 |
Correct |
15 ms |
26068 KB |
Output is correct |
5 |
Correct |
16 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26244 KB |
Output is correct |
7 |
Correct |
16 ms |
26032 KB |
Output is correct |
8 |
Correct |
13 ms |
26068 KB |
Output is correct |
9 |
Correct |
15 ms |
26068 KB |
Output is correct |
10 |
Correct |
13 ms |
26140 KB |
Output is correct |
11 |
Correct |
48 ms |
26440 KB |
Output is correct |
12 |
Incorrect |
36 ms |
26316 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
12 ms |
26084 KB |
Output is correct |
3 |
Correct |
12 ms |
26068 KB |
Output is correct |
4 |
Correct |
15 ms |
26068 KB |
Output is correct |
5 |
Correct |
16 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26244 KB |
Output is correct |
7 |
Correct |
16 ms |
26032 KB |
Output is correct |
8 |
Correct |
13 ms |
26068 KB |
Output is correct |
9 |
Correct |
15 ms |
26068 KB |
Output is correct |
10 |
Correct |
13 ms |
26140 KB |
Output is correct |
11 |
Correct |
48 ms |
26440 KB |
Output is correct |
12 |
Incorrect |
36 ms |
26316 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
26068 KB |
Output is correct |
2 |
Correct |
13 ms |
26068 KB |
Output is correct |
3 |
Correct |
13 ms |
26088 KB |
Output is correct |
4 |
Correct |
13 ms |
26144 KB |
Output is correct |
5 |
Correct |
13 ms |
26068 KB |
Output is correct |
6 |
Correct |
14 ms |
26140 KB |
Output is correct |
7 |
Correct |
13 ms |
26068 KB |
Output is correct |
8 |
Correct |
13 ms |
26140 KB |
Output is correct |
9 |
Correct |
13 ms |
26112 KB |
Output is correct |
10 |
Correct |
14 ms |
26108 KB |
Output is correct |
11 |
Correct |
14 ms |
26040 KB |
Output is correct |
12 |
Correct |
13 ms |
26136 KB |
Output is correct |
13 |
Correct |
16 ms |
26068 KB |
Output is correct |
14 |
Correct |
17 ms |
27680 KB |
Output is correct |
15 |
Incorrect |
14 ms |
27028 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |