이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
pii ymax,zmax,ymax2,zmax2;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ymax={-INF,INF};
zmax={INF,-INF};
ymax2={-INF,INF};
zmax2={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)
{
/// ymax
int z=-1;
for(int j=1;j<i;j++)
if(v[j].y<ymax.first&&v[j].z>ymax.second)
z=max(z,v[j].z);
if(z>p.z&&ymax.first>p.y)
ans=max(ans,ymax.first+z+p.x);
/// zmax
int y=-1;
for(int j=1;j<i;j++)
if(v[j].z<zmax.second&&v[j].y>zmax.first)
y=max(y,v[j].y);
if(y>p.y&&zmax.second>p.z)
ans=max(ans,zmax.second+y+p.x);
/// ymax2
z=-1;
for(int j=1;j<i;j++)
if(v[j].y<ymax2.first&&v[j].z>ymax2.second)
z=max(z,v[j].z);
if(z>p.z&&ymax2.first>p.y)
ans=max(ans,ymax2.first+z+p.x);
/// zmax2
y=-1;
for(int j=1;j<i;j++)
if(v[j].z<zmax2.second&&v[j].y>zmax2.first)
y=max(y,v[j].y);
if(y>p.y&&zmax2.second>p.z)
ans=max(ans,zmax2.second+y+p.x);
}
for(point p:a)
{
if(p.y>ymax.first||(p.y==ymax.first&&p.z<ymax.second))
{
ymax2=ymax;
ymax={p.y,p.z};
}
else if(p.y>ymax2.first||(p.y==ymax2.first&&p.z<ymax2.second))
ymax2={p.y,p.z};
if(p.z>zmax.second||(p.z==zmax.second&&p.y<zmax.first))
{
zmax2=zmax;
zmax={p.y,p.z};
}
else if(p.z>zmax2.second||(p.z==zmax2.second&&p.y<zmax2.first))
zmax2={p.y,p.z};
}
i=j-1;
}
cout<<ans;
return 0;
}
# | 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... |