Submission #770287

# Submission time Handle Problem Language Result Execution time Memory
770287 2023-07-01T04:49:22 Z ttamx Team Contest (JOI22_team) C++14
0 / 100
3 ms 7380 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=150005;

int n,nx,ny,nz;
int x[N],y[N],z[N];
vector<ll> px,py,pz;
vector<int> vx[N],vy[N];
int mx[N];
ll ans=-1;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x[i] >> y[i] >> z[i];
        px.emplace_back(x[i]);
        py.emplace_back(y[i]);
        pz.emplace_back(z[i]);
    }
    px.emplace_back(-3e9);
    py.emplace_back(-3e9);
    pz.emplace_back(-3e9);
    sort(px.begin(),px.end());
    sort(py.begin(),py.end());
    sort(pz.begin(),pz.end());
    px.erase(unique(px.begin(),px.end()),px.end());
    py.erase(unique(py.begin(),py.end()),py.end());
    pz.erase(unique(pz.begin(),pz.end()),pz.end());
    nx=px.size();
    ny=py.size();
    nz=pz.size();
    for(int i=1;i<=n;i++){
        x[i]=lower_bound(px.begin(),px.end(),x[i])-px.begin();
        y[i]=lower_bound(py.begin(),py.end(),y[i])-py.begin();
        z[i]=lower_bound(pz.begin(),pz.end(),z[i])-pz.begin();
        vx[x[i]].emplace_back(i);
    }
    for(int i=1;i<=nx;i++){
        if(vx[i].empty())continue;
        int idx=0;
        for(int j=1;j<=ny;j++){
            mx[j]=0;
            int mn=nz+1;
            for(auto k:vy[j])mn=min(mn,z[k]);
            if(idx>mn)mx[j]=idx;
            for(auto k:vy[j])idx=max(idx,z[k]);
        }
        int mn=ny+1;
        for(auto j:vx[i])mn=min(mn,y[i]);
        ll res=-2e9;
        for(int j=mn+1;j<=ny;j++)if(mx[j])res=max(res,px[i]+py[j]+pz[mx[j]]);
        ans=max(ans,res);
        for(auto j:vx[i])vy[y[j]].emplace_back(j);
    }
    cout << ans;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:54:18: warning: unused variable 'j' [-Wunused-variable]
   54 |         for(auto j:vx[i])mn=min(mn,y[i]);
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7380 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7380 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7380 KB Output is correct
4 Incorrect 3 ms 7380 KB Output isn't correct
5 Halted 0 ms 0 KB -