답안 #892201

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892201 2023-12-25T04:15:21 Z vjudge1 Team Contest (JOI22_team) C++17
26 / 100
2000 ms 29252 KB
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
signed main(){
    int n;
    cin>>n;
    vector <vector <int> > a;
    int mxx=0,mxy=0,mxz=0;
    map <int, vector<pair <int,int> > > mp1,mp2,mp3;
    map <int, vector<int> > mn1,mn2,mn3;
    for(int i=0;i<n;i++){
        int x,y,z;
        cin>>x>>y>>z;
        a.pb({x,y,z});
        mxx=max(mxx,x);
        mxy=max(mxy,y);
        mxz=max(mxz,z);
        mp1[x].pb({y,z});
        mp2[y].pb({x,z});
        mp3[z].pb({x,y});
    }
    for(auto x : mp1){
        sort(all(mp1[x.ff]));
    }
    for(auto x : mp1){
        int mn=1e9;
        for(auto y : x.ss){
            mn=min(mn,y.ss);
            mn1[x.ff].pb(mn);
        }
    }
    for(auto x : mp2){
        sort(all(mp2[x.ff]));
    }
    for(auto x : mp2){
        int mn=1e9;
        for(auto y : x.ss){
            mn=min(mn,y.ss);
            mn2[x.ff].pb(mn);
        }
    }
    for(auto x : mp3){
        sort(all(mp3[x.ff]));
    }
    for(auto x : mp3){
        int mn=1e9;
        for(auto y : x.ss){
            mn=min(mn,y.ss);
            mn3[x.ff].pb(mn);
        }
    }
    
    if(n<=300){
        int res=-1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    bool flag=true;
                    int ans=0;
                    set <int> st;
                    for(int t=0;t<3;t++){
                        int mx=0,cnt=0,x=-1;
                        mx=max(a[i][t],mx);
                        mx=max(a[j][t],mx);
                        mx=max(a[k][t],mx);
                        if(mx==a[i][t]){
                            cnt++;x=i;
                        }
                        if(mx==a[j][t]){
                            cnt++;x=j;
                        }
                        if(mx==a[k][t]){
                            cnt++;x=k;
                        }
                        if(cnt==1){
                            ans+=mx;
                            st.insert(x);
                        }
                        else flag=false;
                    }
                    if(flag && st.size()==3)res=max(res,ans);
                }
            }
        }
        cout<<res<<"\n";return 0;
    }
    
    
    
    int mx=-1;
    for(int i=1;i<=mxx;i++){
        for(int j=1;j<=mxy;j++){
            for(int k=1;k<=mxz;k++){
                
                bool ok1=0,ok2=0,ok3=0;
                if(mp1[i].size()==0 or mp2[j].size()==0 or mp3[k].size()==0)continue;
                
                
                pair <int,int> p={j-1,k};
                auto it=upper_bound(all(mp1[i]),p);
                if(it==mp1[i].end() && mn1[i].back()<k)ok1=1;
                else if(it!=mp1[i].begin() &&  mn1[i][it-mp1[i].begin()-1]<k)ok1=1;
                
                p={i-1,k};
                it=upper_bound(all(mp2[j]),p);
                if(it==mp2[j].end() && mn2[j].back()<k)ok2=1;
                else if(it!=mp2[j].begin() &&  mn2[j][it-mp2[j].begin()-1]<k)ok2=1;
                
                p={i-1,j};
                it=upper_bound(all(mp3[k]),p);
                if(it==mp3[k].end() && mn3[k].back()<j)ok3=1;
                else if(it!=mp3[k].begin() &&  mn3[k][it-mp3[k].begin()-1]<j)ok3=1;
                
                
                if(ok1 && ok2 && ok3){
                    mx=max(mx,i+j+k);
                }
            }
        }
    }
    cout<<mx<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 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 348 KB Output is correct
14 Correct 331 ms 632 KB Output is correct
15 Correct 129 ms 512 KB Output is correct
16 Correct 200 ms 544 KB Output is correct
17 Correct 241 ms 344 KB Output is correct
18 Correct 260 ms 600 KB Output is correct
19 Correct 301 ms 520 KB Output is correct
20 Correct 295 ms 484 KB Output is correct
21 Correct 103 ms 348 KB Output is correct
22 Correct 136 ms 616 KB Output is correct
23 Correct 35 ms 344 KB Output is correct
24 Correct 176 ms 348 KB Output is correct
25 Correct 160 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 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 348 KB Output is correct
14 Correct 331 ms 632 KB Output is correct
15 Correct 129 ms 512 KB Output is correct
16 Correct 200 ms 544 KB Output is correct
17 Correct 241 ms 344 KB Output is correct
18 Correct 260 ms 600 KB Output is correct
19 Correct 301 ms 520 KB Output is correct
20 Correct 295 ms 484 KB Output is correct
21 Correct 103 ms 348 KB Output is correct
22 Correct 136 ms 616 KB Output is correct
23 Correct 35 ms 344 KB Output is correct
24 Correct 176 ms 348 KB Output is correct
25 Correct 160 ms 520 KB Output is correct
26 Execution timed out 2029 ms 3160 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 87 ms 22008 KB Output is correct
12 Correct 56 ms 15444 KB Output is correct
13 Correct 63 ms 19224 KB Output is correct
14 Correct 84 ms 23912 KB Output is correct
15 Correct 78 ms 23884 KB Output is correct
16 Correct 75 ms 29252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 87 ms 22008 KB Output is correct
12 Correct 56 ms 15444 KB Output is correct
13 Correct 63 ms 19224 KB Output is correct
14 Correct 84 ms 23912 KB Output is correct
15 Correct 78 ms 23884 KB Output is correct
16 Correct 75 ms 29252 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 281 ms 484 KB Output is correct
21 Correct 4 ms 604 KB Output is correct
22 Correct 111 ms 20664 KB Output is correct
23 Correct 97 ms 20088 KB Output is correct
24 Correct 74 ms 15868 KB Output is correct
25 Correct 105 ms 22448 KB Output is correct
26 Correct 86 ms 22832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 87 ms 22008 KB Output is correct
12 Correct 56 ms 15444 KB Output is correct
13 Correct 63 ms 19224 KB Output is correct
14 Correct 84 ms 23912 KB Output is correct
15 Correct 78 ms 23884 KB Output is correct
16 Correct 75 ms 29252 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 281 ms 484 KB Output is correct
21 Correct 4 ms 604 KB Output is correct
22 Correct 111 ms 20664 KB Output is correct
23 Correct 97 ms 20088 KB Output is correct
24 Correct 74 ms 15868 KB Output is correct
25 Correct 105 ms 22448 KB Output is correct
26 Correct 86 ms 22832 KB Output is correct
27 Correct 277 ms 532 KB Output is correct
28 Correct 302 ms 520 KB Output is correct
29 Correct 158 ms 344 KB Output is correct
30 Correct 159 ms 344 KB Output is correct
31 Execution timed out 2064 ms 1116 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 87 ms 22008 KB Output is correct
12 Correct 56 ms 15444 KB Output is correct
13 Correct 63 ms 19224 KB Output is correct
14 Correct 84 ms 23912 KB Output is correct
15 Correct 78 ms 23884 KB Output is correct
16 Correct 75 ms 29252 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 281 ms 484 KB Output is correct
21 Correct 4 ms 604 KB Output is correct
22 Correct 111 ms 20664 KB Output is correct
23 Correct 97 ms 20088 KB Output is correct
24 Correct 74 ms 15868 KB Output is correct
25 Correct 105 ms 22448 KB Output is correct
26 Correct 86 ms 22832 KB Output is correct
27 Correct 277 ms 532 KB Output is correct
28 Correct 302 ms 520 KB Output is correct
29 Correct 158 ms 344 KB Output is correct
30 Correct 159 ms 344 KB Output is correct
31 Execution timed out 2064 ms 1116 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 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 348 KB Output is correct
14 Correct 331 ms 632 KB Output is correct
15 Correct 129 ms 512 KB Output is correct
16 Correct 200 ms 544 KB Output is correct
17 Correct 241 ms 344 KB Output is correct
18 Correct 260 ms 600 KB Output is correct
19 Correct 301 ms 520 KB Output is correct
20 Correct 295 ms 484 KB Output is correct
21 Correct 103 ms 348 KB Output is correct
22 Correct 136 ms 616 KB Output is correct
23 Correct 35 ms 344 KB Output is correct
24 Correct 176 ms 348 KB Output is correct
25 Correct 160 ms 520 KB Output is correct
26 Execution timed out 2029 ms 3160 KB Time limit exceeded
27 Halted 0 ms 0 KB -