Submission #634448

# Submission time Handle Problem Language Result Execution time Memory
634448 2022-08-24T12:26:37 Z alvingogo Team Contest (JOI22_team) C++14
100 / 100
93 ms 12940 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

int main(){
    AquA;
    int n;
    cin >> n;
    vector<pair<int,pair<int,int> > > v(n);
    int ans=-1,my=0,mz=0;
    set<pair<int,int> > s;
    for(int i=0;i<n;i++){
        cin >> v[i].fs >> v[i].sc.fs >> v[i].sc.sc;
    }
    sort(v.begin(),v.end());
    vector<pair<int,int> > g;
    for(int i=0;i<n;i++){
        auto h=v[i].sc;
        if(my>h.fs && mz>h.sc){
            ans=max(ans,v[i].fs+my+mz);
        }
        g.push_back(h);
        if(i==n-1 || v[i].fs!=v[i+1].fs){
            for(auto t:g){
                if(s.empty()){
                    if(my<=t.fs && mz<=t.sc){
                        s.insert(t);
                    }
                    else{
                        my=max(my,t.fs);
                        mz=max(mz,t.sc);
                    }
                    continue;
                }
                auto y=s.lower_bound(t);
                auto z=prev(y);
                if((y==s.end() || ((*y).fs>=t.fs && (*y).sc>=t.sc)) && (y==s.begin() || ((*z).fs<=t.fs && (*z).sc<=t.sc))){
                    if(my<=t.fs && mz<=t.sc){
                        s.insert(t);
                    }
                    else{
                        my=max(my,t.fs);
                        mz=max(mz,t.sc);
                    }
                }
                else{
                    for(auto it=s.begin();it!=s.end();it=s.erase(it)){
                        if((*it).fs>=t.fs && (*it).sc>=t.sc){
                            break;
                        }
                        my=max(my,(*it).fs);
                        mz=max(mz,(*it).sc);
                    }
                    my=max(my,t.fs);
                    mz=max(mz,t.sc);
                }
            }
            g.clear();
        }
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 472 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 324 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 3 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 32 ms 2348 KB Output is correct
12 Correct 22 ms 2144 KB Output is correct
13 Correct 25 ms 2392 KB Output is correct
14 Correct 32 ms 3536 KB Output is correct
15 Correct 31 ms 4044 KB Output is correct
16 Correct 28 ms 5136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 32 ms 2348 KB Output is correct
12 Correct 22 ms 2144 KB Output is correct
13 Correct 25 ms 2392 KB Output is correct
14 Correct 32 ms 3536 KB Output is correct
15 Correct 31 ms 4044 KB Output is correct
16 Correct 28 ms 5136 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 42 ms 3212 KB Output is correct
23 Correct 39 ms 3096 KB Output is correct
24 Correct 29 ms 2488 KB Output is correct
25 Correct 41 ms 3588 KB Output is correct
26 Correct 34 ms 4228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 32 ms 2348 KB Output is correct
12 Correct 22 ms 2144 KB Output is correct
13 Correct 25 ms 2392 KB Output is correct
14 Correct 32 ms 3536 KB Output is correct
15 Correct 31 ms 4044 KB Output is correct
16 Correct 28 ms 5136 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 42 ms 3212 KB Output is correct
23 Correct 39 ms 3096 KB Output is correct
24 Correct 29 ms 2488 KB Output is correct
25 Correct 41 ms 3588 KB Output is correct
26 Correct 34 ms 4228 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 316 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 44 ms 3532 KB Output is correct
35 Correct 44 ms 3332 KB Output is correct
36 Correct 49 ms 3608 KB Output is correct
37 Correct 49 ms 3788 KB Output is correct
38 Correct 38 ms 4684 KB Output is correct
39 Correct 20 ms 3532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 32 ms 2348 KB Output is correct
12 Correct 22 ms 2144 KB Output is correct
13 Correct 25 ms 2392 KB Output is correct
14 Correct 32 ms 3536 KB Output is correct
15 Correct 31 ms 4044 KB Output is correct
16 Correct 28 ms 5136 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 42 ms 3212 KB Output is correct
23 Correct 39 ms 3096 KB Output is correct
24 Correct 29 ms 2488 KB Output is correct
25 Correct 41 ms 3588 KB Output is correct
26 Correct 34 ms 4228 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 316 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 44 ms 3532 KB Output is correct
35 Correct 44 ms 3332 KB Output is correct
36 Correct 49 ms 3608 KB Output is correct
37 Correct 49 ms 3788 KB Output is correct
38 Correct 38 ms 4684 KB Output is correct
39 Correct 20 ms 3532 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 3 ms 468 KB Output is correct
44 Correct 48 ms 4056 KB Output is correct
45 Correct 56 ms 4288 KB Output is correct
46 Correct 56 ms 4256 KB Output is correct
47 Correct 58 ms 4412 KB Output is correct
48 Correct 48 ms 5196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 472 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 324 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 3 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 32 ms 2348 KB Output is correct
51 Correct 22 ms 2144 KB Output is correct
52 Correct 25 ms 2392 KB Output is correct
53 Correct 32 ms 3536 KB Output is correct
54 Correct 31 ms 4044 KB Output is correct
55 Correct 28 ms 5136 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 324 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 42 ms 3212 KB Output is correct
62 Correct 39 ms 3096 KB Output is correct
63 Correct 29 ms 2488 KB Output is correct
64 Correct 41 ms 3588 KB Output is correct
65 Correct 34 ms 4228 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 316 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 332 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 44 ms 3532 KB Output is correct
74 Correct 44 ms 3332 KB Output is correct
75 Correct 49 ms 3608 KB Output is correct
76 Correct 49 ms 3788 KB Output is correct
77 Correct 38 ms 4684 KB Output is correct
78 Correct 20 ms 3532 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 2 ms 340 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 3 ms 468 KB Output is correct
83 Correct 48 ms 4056 KB Output is correct
84 Correct 56 ms 4288 KB Output is correct
85 Correct 56 ms 4256 KB Output is correct
86 Correct 58 ms 4412 KB Output is correct
87 Correct 48 ms 5196 KB Output is correct
88 Correct 52 ms 5964 KB Output is correct
89 Correct 69 ms 6664 KB Output is correct
90 Correct 59 ms 6112 KB Output is correct
91 Correct 76 ms 6532 KB Output is correct
92 Correct 58 ms 4888 KB Output is correct
93 Correct 76 ms 5876 KB Output is correct
94 Correct 70 ms 5912 KB Output is correct
95 Correct 65 ms 8456 KB Output is correct
96 Correct 93 ms 12940 KB Output is correct
97 Correct 48 ms 8236 KB Output is correct
98 Correct 80 ms 9240 KB Output is correct
99 Correct 83 ms 9356 KB Output is correct