# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781951 | 2023-07-13T14:06:20 Z | Dymo | Team Contest (JOI22_team) | C++14 | 107 ms | 17100 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" #define pb push_back #define F(i,a,b) for(ll i=a;i<=b;i++) const ll maxn=3e5+10 ; const ll base=3e18; const ll mod= 1e9+7 ; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); /// have medal in APIO /// goal 2/8 ll n; pair<ll,pll> a[maxn]; set<pll> st; set<pll> st1; ll mx=-1; void add(ll x,ll y) { vector<pll> vt; vt.clear(); auto it=st1.upper_bound(make_pair(x,-base)); while (it!=st1.end()&&(*it).ss<=y) { vt.pb(*it); it++; } for (auto p:vt) st1.erase(p); it=st1.upper_bound(make_pair(x,base)); if (it==st1.begin()) { st1.insert(make_pair(x,y)); } else { it--; if ((*it).ss<y) st1.insert(make_pair(x,y)); } } /* 4 5 6 1 7 5 1 5 5 2 4 7 6 */ int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("test.inp","r")) { freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } cin>> n; for (int i=1; i<=n; i++) { cin>> a[i].ff>> a[i].ss.ff>>a[i].ss.ss; } sort(a+1,a+n+1); ll ans=-1; for (int i=1; i<=n; i++) { ll j=i; while (j<=n&&a[j].ff==a[i].ff) j++ ; j--; auto it=st1.upper_bound(make_pair(mx,base)); if (it!=st1.begin()) { it--; ll vals=(*it).ss; for (int t=i;t<=j;t++) { if (a[t].ss.ff<mx&&a[t].ss.ss<vals) { ans=max(ans,mx+vals+a[t].ff); } } } for (int t=i;t<=j;t++) { ll x=a[t].ss.ff; ll y=a[t].ss.ss; add(x+1,y); auto it=st1.upper_bound(make_pair(x,base)); bool chk=false; if (it!=st1.begin()) { it--; if ((*it).ss>y) { chk=true; mx=max(mx,x); } } } i=j; } cout <<ans<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 332 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 | 336 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 332 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 | 336 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 468 KB | Output is correct |
27 | Correct | 2 ms | 444 KB | Output is correct |
28 | Correct | 2 ms | 468 KB | Output is correct |
29 | Correct | 3 ms | 476 KB | Output is correct |
30 | Correct | 2 ms | 380 KB | Output is correct |
31 | Correct | 2 ms | 404 KB | Output is correct |
32 | Correct | 2 ms | 468 KB | Output is correct |
33 | Correct | 2 ms | 468 KB | Output is correct |
34 | Correct | 2 ms | 712 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 | 2 ms | 476 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 328 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 30 ms | 4704 KB | Output is correct |
12 | Correct | 21 ms | 3156 KB | Output is correct |
13 | Correct | 23 ms | 3916 KB | Output is correct |
14 | Correct | 31 ms | 4696 KB | Output is correct |
15 | Correct | 28 ms | 4684 KB | Output is correct |
16 | Correct | 30 ms | 4684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 328 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 30 ms | 4704 KB | Output is correct |
12 | Correct | 21 ms | 3156 KB | Output is correct |
13 | Correct | 23 ms | 3916 KB | Output is correct |
14 | Correct | 31 ms | 4696 KB | Output is correct |
15 | Correct | 28 ms | 4684 KB | Output is correct |
16 | Correct | 30 ms | 4684 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 328 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 40 ms | 5012 KB | Output is correct |
23 | Correct | 33 ms | 4568 KB | Output is correct |
24 | Correct | 26 ms | 3568 KB | Output is correct |
25 | Correct | 36 ms | 4984 KB | Output is correct |
26 | Correct | 29 ms | 4804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 328 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 30 ms | 4704 KB | Output is correct |
12 | Correct | 21 ms | 3156 KB | Output is correct |
13 | Correct | 23 ms | 3916 KB | Output is correct |
14 | Correct | 31 ms | 4696 KB | Output is correct |
15 | Correct | 28 ms | 4684 KB | Output is correct |
16 | Correct | 30 ms | 4684 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 328 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 40 ms | 5012 KB | Output is correct |
23 | Correct | 33 ms | 4568 KB | Output is correct |
24 | Correct | 26 ms | 3568 KB | Output is correct |
25 | Correct | 36 ms | 4984 KB | Output is correct |
26 | Correct | 29 ms | 4804 KB | Output is correct |
27 | Correct | 1 ms | 336 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 468 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 38 ms | 5168 KB | Output is correct |
35 | Correct | 40 ms | 4828 KB | Output is correct |
36 | Correct | 46 ms | 5360 KB | Output is correct |
37 | Correct | 46 ms | 5452 KB | Output is correct |
38 | Correct | 33 ms | 5300 KB | Output is correct |
39 | Correct | 17 ms | 3420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 328 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 30 ms | 4704 KB | Output is correct |
12 | Correct | 21 ms | 3156 KB | Output is correct |
13 | Correct | 23 ms | 3916 KB | Output is correct |
14 | Correct | 31 ms | 4696 KB | Output is correct |
15 | Correct | 28 ms | 4684 KB | Output is correct |
16 | Correct | 30 ms | 4684 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 328 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 40 ms | 5012 KB | Output is correct |
23 | Correct | 33 ms | 4568 KB | Output is correct |
24 | Correct | 26 ms | 3568 KB | Output is correct |
25 | Correct | 36 ms | 4984 KB | Output is correct |
26 | Correct | 29 ms | 4804 KB | Output is correct |
27 | Correct | 1 ms | 336 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 468 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 38 ms | 5168 KB | Output is correct |
35 | Correct | 40 ms | 4828 KB | Output is correct |
36 | Correct | 46 ms | 5360 KB | Output is correct |
37 | Correct | 46 ms | 5452 KB | Output is correct |
38 | Correct | 33 ms | 5300 KB | Output is correct |
39 | Correct | 17 ms | 3420 KB | Output is correct |
40 | Correct | 2 ms | 340 KB | Output is correct |
41 | Correct | 2 ms | 468 KB | Output is correct |
42 | Correct | 2 ms | 468 KB | Output is correct |
43 | Correct | 2 ms | 484 KB | Output is correct |
44 | Correct | 41 ms | 5796 KB | Output is correct |
45 | Correct | 55 ms | 5920 KB | Output is correct |
46 | Correct | 53 ms | 5904 KB | Output is correct |
47 | Correct | 57 ms | 5980 KB | Output is correct |
48 | Correct | 38 ms | 5856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 332 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 | 336 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 468 KB | Output is correct |
27 | Correct | 2 ms | 444 KB | Output is correct |
28 | Correct | 2 ms | 468 KB | Output is correct |
29 | Correct | 3 ms | 476 KB | Output is correct |
30 | Correct | 2 ms | 380 KB | Output is correct |
31 | Correct | 2 ms | 404 KB | Output is correct |
32 | Correct | 2 ms | 468 KB | Output is correct |
33 | Correct | 2 ms | 468 KB | Output is correct |
34 | Correct | 2 ms | 712 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 | 2 ms | 476 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
40 | Correct | 1 ms | 212 KB | Output is correct |
41 | Correct | 0 ms | 212 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 212 KB | Output is correct |
44 | Correct | 0 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 1 ms | 328 KB | Output is correct |
49 | Correct | 1 ms | 212 KB | Output is correct |
50 | Correct | 30 ms | 4704 KB | Output is correct |
51 | Correct | 21 ms | 3156 KB | Output is correct |
52 | Correct | 23 ms | 3916 KB | Output is correct |
53 | Correct | 31 ms | 4696 KB | Output is correct |
54 | Correct | 28 ms | 4684 KB | Output is correct |
55 | Correct | 30 ms | 4684 KB | Output is correct |
56 | Correct | 1 ms | 332 KB | Output is correct |
57 | Correct | 1 ms | 328 KB | Output is correct |
58 | Correct | 1 ms | 212 KB | Output is correct |
59 | Correct | 1 ms | 340 KB | Output is correct |
60 | Correct | 1 ms | 340 KB | Output is correct |
61 | Correct | 40 ms | 5012 KB | Output is correct |
62 | Correct | 33 ms | 4568 KB | Output is correct |
63 | Correct | 26 ms | 3568 KB | Output is correct |
64 | Correct | 36 ms | 4984 KB | Output is correct |
65 | Correct | 29 ms | 4804 KB | Output is correct |
66 | Correct | 1 ms | 336 KB | Output is correct |
67 | Correct | 1 ms | 340 KB | Output is correct |
68 | Correct | 1 ms | 340 KB | Output is correct |
69 | Correct | 1 ms | 340 KB | Output is correct |
70 | Correct | 2 ms | 468 KB | Output is correct |
71 | Correct | 1 ms | 340 KB | Output is correct |
72 | Correct | 1 ms | 340 KB | Output is correct |
73 | Correct | 38 ms | 5168 KB | Output is correct |
74 | Correct | 40 ms | 4828 KB | Output is correct |
75 | Correct | 46 ms | 5360 KB | Output is correct |
76 | Correct | 46 ms | 5452 KB | Output is correct |
77 | Correct | 33 ms | 5300 KB | Output is correct |
78 | Correct | 17 ms | 3420 KB | Output is correct |
79 | Correct | 2 ms | 340 KB | Output is correct |
80 | Correct | 2 ms | 468 KB | Output is correct |
81 | Correct | 2 ms | 468 KB | Output is correct |
82 | Correct | 2 ms | 484 KB | Output is correct |
83 | Correct | 41 ms | 5796 KB | Output is correct |
84 | Correct | 55 ms | 5920 KB | Output is correct |
85 | Correct | 53 ms | 5904 KB | Output is correct |
86 | Correct | 57 ms | 5980 KB | Output is correct |
87 | Correct | 38 ms | 5856 KB | Output is correct |
88 | Correct | 49 ms | 7756 KB | Output is correct |
89 | Correct | 73 ms | 8548 KB | Output is correct |
90 | Correct | 57 ms | 7884 KB | Output is correct |
91 | Correct | 86 ms | 8380 KB | Output is correct |
92 | Correct | 56 ms | 6552 KB | Output is correct |
93 | Correct | 85 ms | 7608 KB | Output is correct |
94 | Correct | 79 ms | 7244 KB | Output is correct |
95 | Correct | 47 ms | 7608 KB | Output is correct |
96 | Correct | 107 ms | 17100 KB | Output is correct |
97 | Correct | 45 ms | 7744 KB | Output is correct |
98 | Correct | 76 ms | 7944 KB | Output is correct |
99 | Correct | 90 ms | 7940 KB | Output is correct |