#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int INF=1e9;
int n;
struct point
{
int x,y,z;
} v[150005];
bool byx(point a,point b)
{
return a.x<b.x;
}
bool byy(pii a,pii b)
{
if(a.first!=b.first)
return a.first>b.first;
return a.second<b.second;
}
bool byz(pii a,pii b)
{
if(a.second!=b.second)
return a.second>b.second;
return a.first<b.first;
}
vector<pii> myy,myz;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
myy.push_back({-INF,INF});
myz.push_back({INF,-INF});
cin>>n;
for(int i=1;i<=n;i++)
cin>>v[i].x>>v[i].y>>v[i].z;
int ans=-1;
sort(v+1,v+n+1,byx);
for(int i=1;i<=n;i++)
{
vector<point> a;
int j=i;
while(j<=n&&v[j].x==v[i].x)
{
a.push_back(v[j]);
j++;
}
for(point p:a)
{
for(pii ymax:myy)
{
if(ymax.first<=p.y)
continue;
int z=-1;
for(pii a:myz)
if(a.first<ymax.first&&a.second>ymax.second)
z=max(z,a.second);
if(z>p.z)
ans=max(ans,ymax.first+z+p.x);
}
for(pii zmax:myz)
{
if(zmax.second<=p.z)
continue;
int y=-1;
for(pii a:myy)
if(a.second<zmax.second&&a.first>zmax.first)
y=max(y,a.first);
if(y>p.y)
ans=max(ans,zmax.second+y+p.x);
}
}
for(point p:a)
{
myy.push_back({p.y,p.z});
sort(myy.begin(),myy.end(),byy);
myy.erase(unique(myy.begin(),myy.end()),myy.end());
if(myy.size()>200)
myy.pop_back();
myz.push_back({p.y,p.z});
sort(myz.begin(),myz.end(),byz);
myz.erase(unique(myz.begin(),myz.end()),myz.end());
if(myz.size()>200)
myz.pop_back();
}
i=j-1;
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
17 ms |
348 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
480 KB |
Output is correct |
17 |
Correct |
8 ms |
348 KB |
Output is correct |
18 |
Correct |
14 ms |
344 KB |
Output is correct |
19 |
Correct |
14 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
5 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
17 ms |
348 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
480 KB |
Output is correct |
17 |
Correct |
8 ms |
348 KB |
Output is correct |
18 |
Correct |
14 ms |
344 KB |
Output is correct |
19 |
Correct |
14 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
5 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
4 ms |
348 KB |
Output is correct |
26 |
Correct |
336 ms |
496 KB |
Output is correct |
27 |
Correct |
289 ms |
500 KB |
Output is correct |
28 |
Incorrect |
281 ms |
608 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
360 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
235 ms |
2948 KB |
Output is correct |
12 |
Correct |
80 ms |
2392 KB |
Output is correct |
13 |
Correct |
55 ms |
3136 KB |
Output is correct |
14 |
Correct |
105 ms |
3376 KB |
Output is correct |
15 |
Correct |
49 ms |
4368 KB |
Output is correct |
16 |
Correct |
31 ms |
5328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
360 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
235 ms |
2948 KB |
Output is correct |
12 |
Correct |
80 ms |
2392 KB |
Output is correct |
13 |
Correct |
55 ms |
3136 KB |
Output is correct |
14 |
Correct |
105 ms |
3376 KB |
Output is correct |
15 |
Correct |
49 ms |
4368 KB |
Output is correct |
16 |
Correct |
31 ms |
5328 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
141 ms |
480 KB |
Output is correct |
22 |
Execution timed out |
2063 ms |
2388 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
360 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
235 ms |
2948 KB |
Output is correct |
12 |
Correct |
80 ms |
2392 KB |
Output is correct |
13 |
Correct |
55 ms |
3136 KB |
Output is correct |
14 |
Correct |
105 ms |
3376 KB |
Output is correct |
15 |
Correct |
49 ms |
4368 KB |
Output is correct |
16 |
Correct |
31 ms |
5328 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
141 ms |
480 KB |
Output is correct |
22 |
Execution timed out |
2063 ms |
2388 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
360 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
235 ms |
2948 KB |
Output is correct |
12 |
Correct |
80 ms |
2392 KB |
Output is correct |
13 |
Correct |
55 ms |
3136 KB |
Output is correct |
14 |
Correct |
105 ms |
3376 KB |
Output is correct |
15 |
Correct |
49 ms |
4368 KB |
Output is correct |
16 |
Correct |
31 ms |
5328 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
141 ms |
480 KB |
Output is correct |
22 |
Execution timed out |
2063 ms |
2388 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
17 ms |
348 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
480 KB |
Output is correct |
17 |
Correct |
8 ms |
348 KB |
Output is correct |
18 |
Correct |
14 ms |
344 KB |
Output is correct |
19 |
Correct |
14 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
5 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
4 ms |
348 KB |
Output is correct |
26 |
Correct |
336 ms |
496 KB |
Output is correct |
27 |
Correct |
289 ms |
500 KB |
Output is correct |
28 |
Incorrect |
281 ms |
608 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |