Submission #925707

# Submission time Handle Problem Language Result Execution time Memory
925707 2024-02-12T07:43:43 Z andrei_boaca Team Contest (JOI22_team) C++17
0 / 100
2000 ms 3636 KB
#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)
        {
            if(ymax.first<=p.y||zmax.second<=p.z)
                continue;
            /// 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)
                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)
                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)
                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)
                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
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 3636 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 3636 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 3636 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 3636 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 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 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -