답안 #545304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545304 2022-04-04T08:24:23 Z leaked Team Contest (JOI22_team) C++14
100 / 100
613 ms 23556 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pb push_back
#define sz(x) (int)(x).size()
#define pw(x) (1LL<<(x))
#define fast_resp ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef pair<int,ll> pil;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const ll inf=1e18;
const int N=160'000+1;
int mx[4*N],mn[4*N];
void upd(int i,int x,int v,int tl,int tr){
    if(tl==tr){
        umax(mx[v],x);umin(mn[v],x);
        return;
    }
    int tm=(tl+tr)>>1;
    if(tm>=i)
        upd(i,x,2*v,tl,tm);
    else
        upd(i,x,2*v+1,tm+1,tr);
    mx[v]=max(mx[v<<1],mx[v<<1|1]);
    mn[v]=min(mn[v<<1],mn[v<<1|1]);
}
int getmax(int l,int r,int v,int tl,int tr){
    if(tl>=l&&tr<=r) return mx[v];
    if(tl>r||tr<l) return -1e9;
    int tm=(tl+tr)>>1;
    return max(getmax(l,r,v<<1,tl,tm),getmax(l,r,v<<1|1,tm+1,tr));
}
int getmin(int l,int r,int v,int tl,int tr){
    if(tl>=l&&tr<=r) return mn[v];
    if(tl>r||tr<l) return 1e9;
    int tm=(tl+tr)>>1;
    return min(getmin(l,r,v<<1,tl,tm),getmin(l,r,v<<1|1,tm+1,tr));
}
signed main(){
    fast_resp;
    int n;
    cin>>n;
    vec<vec<int>>a(n,vec<int>(3));
    vec<vec<int>> kek(3);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
            kek[j].pb(a[i][j]);
        }
    }
    for(int j=0;j<3;j++){
        sort(all(kek[j]));
        kek[j].erase(unique(all(kek[j])),kek[j].end());
    }
    vec<vec<int>> ids(n,vec<int>());
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            a[i][j]=lower_bound(all(kek[j]),a[i][j])-kek[j].begin();
        ids[a[i][0]].pb(i);
    }
    int mxt=-1;
    fill(mx,mx+4*N,-1e9);fill(mn,mn+4*N,1e9);
    int m=sz(kek[1]);
    int j=-1;
    for(int x=0;x<n;x++){
        for(auto &i : ids[x]){
            if(j<=a[i][1]) continue;
//            cout<<"WO "<<j<<' '<<a[i][1]<<' '<<getmax(0,j,1,0,endl;
            if(getmax(0,j-1,1,0,m-1)>max(getmin(j,m-1,1,0,m-1),a[i][2])){
                umax(mxt,kek[0][a[i][0]]+kek[1][j]+kek[2][getmax(0,j-1,1,0,m-1)]);
            }
        }
        for(auto &i : ids[x]){
//            cout<<"ADD "<<a[i][1]<<' '<<a[i][2]<<endl;
            upd(a[i][1],a[i][2],1,0,m-1);
        }
//        if(kek[0][x]==4){
//            x=x;
//            cout<<"W "<<endl;
//        }
        for(auto &i : ids[x]){
            /// suppose i'm in prefmax
            int l=a[i][1]+1,r=m;
            while(l!=r){
                int tm=(l+r)>>1;
                if(getmin(tm,m-1,1,0,m-1)<a[i][2]) l=tm+1;
                else r=tm;
            }
            --l;
            if(l!=a[i][1]) umax(j,l);
            ///i'ma sufmin
            if(getmax(0,a[i][1]-1,1,0,m-1)>a[i][2]){
                umax(j,a[i][1]);
            }
        }
    }
    cout<<mxt;
    return 0;
}
/*

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5332 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 4 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5332 KB Output is correct
11 Correct 3 ms 5204 KB Output is correct
12 Correct 3 ms 5204 KB Output is correct
13 Correct 3 ms 5292 KB Output is correct
14 Correct 4 ms 5332 KB Output is correct
15 Correct 3 ms 5332 KB Output is correct
16 Correct 3 ms 5332 KB Output is correct
17 Correct 3 ms 5332 KB Output is correct
18 Correct 3 ms 5332 KB Output is correct
19 Correct 3 ms 5332 KB Output is correct
20 Correct 3 ms 5344 KB Output is correct
21 Correct 3 ms 5332 KB Output is correct
22 Correct 4 ms 5260 KB Output is correct
23 Correct 3 ms 5332 KB Output is correct
24 Correct 3 ms 5332 KB Output is correct
25 Correct 3 ms 5332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5332 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 4 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5332 KB Output is correct
11 Correct 3 ms 5204 KB Output is correct
12 Correct 3 ms 5204 KB Output is correct
13 Correct 3 ms 5292 KB Output is correct
14 Correct 4 ms 5332 KB Output is correct
15 Correct 3 ms 5332 KB Output is correct
16 Correct 3 ms 5332 KB Output is correct
17 Correct 3 ms 5332 KB Output is correct
18 Correct 3 ms 5332 KB Output is correct
19 Correct 3 ms 5332 KB Output is correct
20 Correct 3 ms 5344 KB Output is correct
21 Correct 3 ms 5332 KB Output is correct
22 Correct 4 ms 5260 KB Output is correct
23 Correct 3 ms 5332 KB Output is correct
24 Correct 3 ms 5332 KB Output is correct
25 Correct 3 ms 5332 KB Output is correct
26 Correct 12 ms 5716 KB Output is correct
27 Correct 11 ms 5772 KB Output is correct
28 Correct 14 ms 5648 KB Output is correct
29 Correct 10 ms 5752 KB Output is correct
30 Correct 8 ms 5588 KB Output is correct
31 Correct 10 ms 5744 KB Output is correct
32 Correct 8 ms 5716 KB Output is correct
33 Correct 6 ms 5716 KB Output is correct
34 Correct 12 ms 5716 KB Output is correct
35 Correct 4 ms 5332 KB Output is correct
36 Correct 4 ms 5332 KB Output is correct
37 Correct 9 ms 5716 KB Output is correct
38 Correct 11 ms 5716 KB Output is correct
39 Correct 4 ms 5460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5204 KB Output is correct
4 Correct 3 ms 5244 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 3 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5204 KB Output is correct
11 Correct 99 ms 19668 KB Output is correct
12 Correct 52 ms 14980 KB Output is correct
13 Correct 53 ms 17160 KB Output is correct
14 Correct 69 ms 19920 KB Output is correct
15 Correct 60 ms 19784 KB Output is correct
16 Correct 54 ms 19476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5204 KB Output is correct
4 Correct 3 ms 5244 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 3 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5204 KB Output is correct
11 Correct 99 ms 19668 KB Output is correct
12 Correct 52 ms 14980 KB Output is correct
13 Correct 53 ms 17160 KB Output is correct
14 Correct 69 ms 19920 KB Output is correct
15 Correct 60 ms 19784 KB Output is correct
16 Correct 54 ms 19476 KB Output is correct
17 Correct 3 ms 5204 KB Output is correct
18 Correct 3 ms 5204 KB Output is correct
19 Correct 3 ms 5204 KB Output is correct
20 Correct 3 ms 5332 KB Output is correct
21 Correct 4 ms 5492 KB Output is correct
22 Correct 123 ms 19600 KB Output is correct
23 Correct 106 ms 19260 KB Output is correct
24 Correct 79 ms 15728 KB Output is correct
25 Correct 106 ms 19628 KB Output is correct
26 Correct 65 ms 19792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5204 KB Output is correct
4 Correct 3 ms 5244 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 3 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5204 KB Output is correct
11 Correct 99 ms 19668 KB Output is correct
12 Correct 52 ms 14980 KB Output is correct
13 Correct 53 ms 17160 KB Output is correct
14 Correct 69 ms 19920 KB Output is correct
15 Correct 60 ms 19784 KB Output is correct
16 Correct 54 ms 19476 KB Output is correct
17 Correct 3 ms 5204 KB Output is correct
18 Correct 3 ms 5204 KB Output is correct
19 Correct 3 ms 5204 KB Output is correct
20 Correct 3 ms 5332 KB Output is correct
21 Correct 4 ms 5492 KB Output is correct
22 Correct 123 ms 19600 KB Output is correct
23 Correct 106 ms 19260 KB Output is correct
24 Correct 79 ms 15728 KB Output is correct
25 Correct 106 ms 19628 KB Output is correct
26 Correct 65 ms 19792 KB Output is correct
27 Correct 3 ms 5332 KB Output is correct
28 Correct 3 ms 5332 KB Output is correct
29 Correct 3 ms 5272 KB Output is correct
30 Correct 3 ms 5332 KB Output is correct
31 Correct 10 ms 5716 KB Output is correct
32 Correct 4 ms 5428 KB Output is correct
33 Correct 4 ms 5332 KB Output is correct
34 Correct 223 ms 18928 KB Output is correct
35 Correct 188 ms 18588 KB Output is correct
36 Correct 224 ms 19848 KB Output is correct
37 Correct 198 ms 19644 KB Output is correct
38 Correct 91 ms 19496 KB Output is correct
39 Correct 77 ms 13936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5204 KB Output is correct
4 Correct 3 ms 5244 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 3 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5204 KB Output is correct
11 Correct 99 ms 19668 KB Output is correct
12 Correct 52 ms 14980 KB Output is correct
13 Correct 53 ms 17160 KB Output is correct
14 Correct 69 ms 19920 KB Output is correct
15 Correct 60 ms 19784 KB Output is correct
16 Correct 54 ms 19476 KB Output is correct
17 Correct 3 ms 5204 KB Output is correct
18 Correct 3 ms 5204 KB Output is correct
19 Correct 3 ms 5204 KB Output is correct
20 Correct 3 ms 5332 KB Output is correct
21 Correct 4 ms 5492 KB Output is correct
22 Correct 123 ms 19600 KB Output is correct
23 Correct 106 ms 19260 KB Output is correct
24 Correct 79 ms 15728 KB Output is correct
25 Correct 106 ms 19628 KB Output is correct
26 Correct 65 ms 19792 KB Output is correct
27 Correct 3 ms 5332 KB Output is correct
28 Correct 3 ms 5332 KB Output is correct
29 Correct 3 ms 5272 KB Output is correct
30 Correct 3 ms 5332 KB Output is correct
31 Correct 10 ms 5716 KB Output is correct
32 Correct 4 ms 5428 KB Output is correct
33 Correct 4 ms 5332 KB Output is correct
34 Correct 223 ms 18928 KB Output is correct
35 Correct 188 ms 18588 KB Output is correct
36 Correct 224 ms 19848 KB Output is correct
37 Correct 198 ms 19644 KB Output is correct
38 Correct 91 ms 19496 KB Output is correct
39 Correct 77 ms 13936 KB Output is correct
40 Correct 8 ms 5588 KB Output is correct
41 Correct 10 ms 5716 KB Output is correct
42 Correct 9 ms 5752 KB Output is correct
43 Correct 12 ms 5692 KB Output is correct
44 Correct 347 ms 19952 KB Output is correct
45 Correct 301 ms 19752 KB Output is correct
46 Correct 335 ms 19900 KB Output is correct
47 Correct 290 ms 19792 KB Output is correct
48 Correct 134 ms 19760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 3 ms 5204 KB Output is correct
3 Correct 3 ms 5332 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 3 ms 5204 KB Output is correct
6 Correct 3 ms 5204 KB Output is correct
7 Correct 3 ms 5204 KB Output is correct
8 Correct 4 ms 5332 KB Output is correct
9 Correct 3 ms 5204 KB Output is correct
10 Correct 3 ms 5332 KB Output is correct
11 Correct 3 ms 5204 KB Output is correct
12 Correct 3 ms 5204 KB Output is correct
13 Correct 3 ms 5292 KB Output is correct
14 Correct 4 ms 5332 KB Output is correct
15 Correct 3 ms 5332 KB Output is correct
16 Correct 3 ms 5332 KB Output is correct
17 Correct 3 ms 5332 KB Output is correct
18 Correct 3 ms 5332 KB Output is correct
19 Correct 3 ms 5332 KB Output is correct
20 Correct 3 ms 5344 KB Output is correct
21 Correct 3 ms 5332 KB Output is correct
22 Correct 4 ms 5260 KB Output is correct
23 Correct 3 ms 5332 KB Output is correct
24 Correct 3 ms 5332 KB Output is correct
25 Correct 3 ms 5332 KB Output is correct
26 Correct 12 ms 5716 KB Output is correct
27 Correct 11 ms 5772 KB Output is correct
28 Correct 14 ms 5648 KB Output is correct
29 Correct 10 ms 5752 KB Output is correct
30 Correct 8 ms 5588 KB Output is correct
31 Correct 10 ms 5744 KB Output is correct
32 Correct 8 ms 5716 KB Output is correct
33 Correct 6 ms 5716 KB Output is correct
34 Correct 12 ms 5716 KB Output is correct
35 Correct 4 ms 5332 KB Output is correct
36 Correct 4 ms 5332 KB Output is correct
37 Correct 9 ms 5716 KB Output is correct
38 Correct 11 ms 5716 KB Output is correct
39 Correct 4 ms 5460 KB Output is correct
40 Correct 3 ms 5204 KB Output is correct
41 Correct 3 ms 5204 KB Output is correct
42 Correct 3 ms 5204 KB Output is correct
43 Correct 3 ms 5244 KB Output is correct
44 Correct 3 ms 5204 KB Output is correct
45 Correct 3 ms 5204 KB Output is correct
46 Correct 3 ms 5204 KB Output is correct
47 Correct 3 ms 5332 KB Output is correct
48 Correct 3 ms 5204 KB Output is correct
49 Correct 3 ms 5204 KB Output is correct
50 Correct 99 ms 19668 KB Output is correct
51 Correct 52 ms 14980 KB Output is correct
52 Correct 53 ms 17160 KB Output is correct
53 Correct 69 ms 19920 KB Output is correct
54 Correct 60 ms 19784 KB Output is correct
55 Correct 54 ms 19476 KB Output is correct
56 Correct 3 ms 5204 KB Output is correct
57 Correct 3 ms 5204 KB Output is correct
58 Correct 3 ms 5204 KB Output is correct
59 Correct 3 ms 5332 KB Output is correct
60 Correct 4 ms 5492 KB Output is correct
61 Correct 123 ms 19600 KB Output is correct
62 Correct 106 ms 19260 KB Output is correct
63 Correct 79 ms 15728 KB Output is correct
64 Correct 106 ms 19628 KB Output is correct
65 Correct 65 ms 19792 KB Output is correct
66 Correct 3 ms 5332 KB Output is correct
67 Correct 3 ms 5332 KB Output is correct
68 Correct 3 ms 5272 KB Output is correct
69 Correct 3 ms 5332 KB Output is correct
70 Correct 10 ms 5716 KB Output is correct
71 Correct 4 ms 5428 KB Output is correct
72 Correct 4 ms 5332 KB Output is correct
73 Correct 223 ms 18928 KB Output is correct
74 Correct 188 ms 18588 KB Output is correct
75 Correct 224 ms 19848 KB Output is correct
76 Correct 198 ms 19644 KB Output is correct
77 Correct 91 ms 19496 KB Output is correct
78 Correct 77 ms 13936 KB Output is correct
79 Correct 8 ms 5588 KB Output is correct
80 Correct 10 ms 5716 KB Output is correct
81 Correct 9 ms 5752 KB Output is correct
82 Correct 12 ms 5692 KB Output is correct
83 Correct 347 ms 19952 KB Output is correct
84 Correct 301 ms 19752 KB Output is correct
85 Correct 335 ms 19900 KB Output is correct
86 Correct 290 ms 19792 KB Output is correct
87 Correct 134 ms 19760 KB Output is correct
88 Correct 613 ms 23556 KB Output is correct
89 Correct 572 ms 21448 KB Output is correct
90 Correct 594 ms 21896 KB Output is correct
91 Correct 598 ms 21160 KB Output is correct
92 Correct 495 ms 20304 KB Output is correct
93 Correct 589 ms 21632 KB Output is correct
94 Correct 494 ms 20760 KB Output is correct
95 Correct 215 ms 20520 KB Output is correct
96 Correct 591 ms 23536 KB Output is correct
97 Correct 67 ms 19500 KB Output is correct
98 Correct 376 ms 20632 KB Output is correct
99 Correct 393 ms 20628 KB Output is correct