#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include<bits/stdc++.h>
//#define int long long
#define quick ios::sync_with_stdio(0);cin.tie(0);
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define repd(x,a,b) for(int x=a;x>=b;x--)
#define lowbit(x) (x&-x)
#define sz(x) (int)(x.size())
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define eb emplace_back
using namespace std;
typedef pair<int,int> pii;
void debug(){
cout<<"\n";
}
template <class T,class ... U >
void debug(T a, U ... b){
cout<<a<<" ",debug(b...);
}
const int N=2e5+7;
const int INF=1e9;
int bit[N];
int x[N];
int y[N];
int z[N];
vector<pii> v[N];
int yz[N];
void upd(int x,int val){
for(;x<N;x+=lowbit(x)) bit[x]=max(bit[x],val);
}
int qry(int x){
int ret=0;
for(;x>0;x-=lowbit(x)) ret=max(ret,bit[x]);
return ret;
}
signed main(){
quick
int n;
cin>>n;
vector<int> vx;
vector<int> vy;
vector<int> vz;
rep(i,0,n-1){
cin>>x[i]>>y[i]>>z[i];
vx.eb(x[i]);
vy.eb(y[i]);
vz.eb(z[i]);
}
sort(all(vx));
sort(all(vy));
sort(all(vz));
vx.erase(unique(all(vx)),vx.end());
vy.erase(unique(all(vy)),vy.end());
vz.erase(unique(all(vz)),vz.end());
int ans=-1;
rep(i,0,n-1){
x[i]=upper_bound(all(vx),x[i])-vx.begin();
y[i]=upper_bound(all(vy),y[i])-vy.begin();
z[i]=upper_bound(all(vz),z[i])-vz.begin();
v[x[i]].eb(mp(y[i],z[i]));
yz[y[i]]=INF;
}
int Best=-1;
rep(i,1,sz(vx)){
for(pii p2:v[i]){
if(Best>p2.F&&qry(Best-1)>p2.S){
ans=max(ans,vx[i-1]+vy[Best-1]+vz[qry(Best-1)-1]);
}
}
for(pii p2:v[i]){
yz[p2.F]=min(yz[p2.F],p2.S);
if(qry(p2.F-1)>yz[p2.F]){
Best=max(Best,p2.F);
}
upd(p2.F,p2.S);
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5036 KB |
Output is correct |
2 |
Correct |
4 ms |
5040 KB |
Output is correct |
3 |
Correct |
4 ms |
4968 KB |
Output is correct |
4 |
Correct |
5 ms |
5080 KB |
Output is correct |
5 |
Correct |
4 ms |
5088 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5000 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5036 KB |
Output is correct |
11 |
Correct |
3 ms |
5076 KB |
Output is correct |
12 |
Correct |
5 ms |
5076 KB |
Output is correct |
13 |
Correct |
4 ms |
5076 KB |
Output is correct |
14 |
Correct |
3 ms |
5076 KB |
Output is correct |
15 |
Correct |
3 ms |
5076 KB |
Output is correct |
16 |
Correct |
5 ms |
5044 KB |
Output is correct |
17 |
Correct |
4 ms |
5076 KB |
Output is correct |
18 |
Correct |
4 ms |
5036 KB |
Output is correct |
19 |
Correct |
4 ms |
5036 KB |
Output is correct |
20 |
Correct |
4 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5040 KB |
Output is correct |
23 |
Correct |
4 ms |
5076 KB |
Output is correct |
24 |
Correct |
4 ms |
5076 KB |
Output is correct |
25 |
Correct |
3 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5036 KB |
Output is correct |
2 |
Correct |
4 ms |
5040 KB |
Output is correct |
3 |
Correct |
4 ms |
4968 KB |
Output is correct |
4 |
Correct |
5 ms |
5080 KB |
Output is correct |
5 |
Correct |
4 ms |
5088 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5000 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5036 KB |
Output is correct |
11 |
Correct |
3 ms |
5076 KB |
Output is correct |
12 |
Correct |
5 ms |
5076 KB |
Output is correct |
13 |
Correct |
4 ms |
5076 KB |
Output is correct |
14 |
Correct |
3 ms |
5076 KB |
Output is correct |
15 |
Correct |
3 ms |
5076 KB |
Output is correct |
16 |
Correct |
5 ms |
5044 KB |
Output is correct |
17 |
Correct |
4 ms |
5076 KB |
Output is correct |
18 |
Correct |
4 ms |
5036 KB |
Output is correct |
19 |
Correct |
4 ms |
5036 KB |
Output is correct |
20 |
Correct |
4 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5040 KB |
Output is correct |
23 |
Correct |
4 ms |
5076 KB |
Output is correct |
24 |
Correct |
4 ms |
5076 KB |
Output is correct |
25 |
Correct |
3 ms |
5076 KB |
Output is correct |
26 |
Correct |
7 ms |
5428 KB |
Output is correct |
27 |
Correct |
8 ms |
5332 KB |
Output is correct |
28 |
Correct |
6 ms |
5332 KB |
Output is correct |
29 |
Correct |
6 ms |
5332 KB |
Output is correct |
30 |
Correct |
6 ms |
5156 KB |
Output is correct |
31 |
Correct |
6 ms |
5204 KB |
Output is correct |
32 |
Correct |
5 ms |
5204 KB |
Output is correct |
33 |
Correct |
6 ms |
5308 KB |
Output is correct |
34 |
Correct |
7 ms |
5348 KB |
Output is correct |
35 |
Correct |
4 ms |
5076 KB |
Output is correct |
36 |
Correct |
4 ms |
5076 KB |
Output is correct |
37 |
Correct |
5 ms |
5204 KB |
Output is correct |
38 |
Correct |
7 ms |
5204 KB |
Output is correct |
39 |
Correct |
4 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
3 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5076 KB |
Output is correct |
9 |
Correct |
3 ms |
5076 KB |
Output is correct |
10 |
Correct |
5 ms |
5032 KB |
Output is correct |
11 |
Correct |
49 ms |
10296 KB |
Output is correct |
12 |
Correct |
37 ms |
8864 KB |
Output is correct |
13 |
Correct |
35 ms |
9620 KB |
Output is correct |
14 |
Correct |
50 ms |
11052 KB |
Output is correct |
15 |
Correct |
50 ms |
10600 KB |
Output is correct |
16 |
Correct |
44 ms |
10832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
3 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5076 KB |
Output is correct |
9 |
Correct |
3 ms |
5076 KB |
Output is correct |
10 |
Correct |
5 ms |
5032 KB |
Output is correct |
11 |
Correct |
49 ms |
10296 KB |
Output is correct |
12 |
Correct |
37 ms |
8864 KB |
Output is correct |
13 |
Correct |
35 ms |
9620 KB |
Output is correct |
14 |
Correct |
50 ms |
11052 KB |
Output is correct |
15 |
Correct |
50 ms |
10600 KB |
Output is correct |
16 |
Correct |
44 ms |
10832 KB |
Output is correct |
17 |
Correct |
3 ms |
5032 KB |
Output is correct |
18 |
Correct |
3 ms |
5076 KB |
Output is correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
4 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5108 KB |
Output is correct |
22 |
Correct |
67 ms |
10124 KB |
Output is correct |
23 |
Correct |
57 ms |
9872 KB |
Output is correct |
24 |
Correct |
46 ms |
9464 KB |
Output is correct |
25 |
Correct |
57 ms |
11008 KB |
Output is correct |
26 |
Correct |
43 ms |
11144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
3 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5076 KB |
Output is correct |
9 |
Correct |
3 ms |
5076 KB |
Output is correct |
10 |
Correct |
5 ms |
5032 KB |
Output is correct |
11 |
Correct |
49 ms |
10296 KB |
Output is correct |
12 |
Correct |
37 ms |
8864 KB |
Output is correct |
13 |
Correct |
35 ms |
9620 KB |
Output is correct |
14 |
Correct |
50 ms |
11052 KB |
Output is correct |
15 |
Correct |
50 ms |
10600 KB |
Output is correct |
16 |
Correct |
44 ms |
10832 KB |
Output is correct |
17 |
Correct |
3 ms |
5032 KB |
Output is correct |
18 |
Correct |
3 ms |
5076 KB |
Output is correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
4 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5108 KB |
Output is correct |
22 |
Correct |
67 ms |
10124 KB |
Output is correct |
23 |
Correct |
57 ms |
9872 KB |
Output is correct |
24 |
Correct |
46 ms |
9464 KB |
Output is correct |
25 |
Correct |
57 ms |
11008 KB |
Output is correct |
26 |
Correct |
43 ms |
11144 KB |
Output is correct |
27 |
Correct |
3 ms |
5076 KB |
Output is correct |
28 |
Correct |
3 ms |
5040 KB |
Output is correct |
29 |
Correct |
4 ms |
5036 KB |
Output is correct |
30 |
Correct |
3 ms |
5076 KB |
Output is correct |
31 |
Correct |
6 ms |
5168 KB |
Output is correct |
32 |
Correct |
4 ms |
5076 KB |
Output is correct |
33 |
Correct |
4 ms |
5188 KB |
Output is correct |
34 |
Correct |
85 ms |
10552 KB |
Output is correct |
35 |
Correct |
76 ms |
10904 KB |
Output is correct |
36 |
Correct |
83 ms |
11196 KB |
Output is correct |
37 |
Correct |
80 ms |
10992 KB |
Output is correct |
38 |
Correct |
60 ms |
11184 KB |
Output is correct |
39 |
Correct |
34 ms |
9000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5076 KB |
Output is correct |
2 |
Correct |
3 ms |
5076 KB |
Output is correct |
3 |
Correct |
3 ms |
5076 KB |
Output is correct |
4 |
Correct |
3 ms |
5076 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5076 KB |
Output is correct |
9 |
Correct |
3 ms |
5076 KB |
Output is correct |
10 |
Correct |
5 ms |
5032 KB |
Output is correct |
11 |
Correct |
49 ms |
10296 KB |
Output is correct |
12 |
Correct |
37 ms |
8864 KB |
Output is correct |
13 |
Correct |
35 ms |
9620 KB |
Output is correct |
14 |
Correct |
50 ms |
11052 KB |
Output is correct |
15 |
Correct |
50 ms |
10600 KB |
Output is correct |
16 |
Correct |
44 ms |
10832 KB |
Output is correct |
17 |
Correct |
3 ms |
5032 KB |
Output is correct |
18 |
Correct |
3 ms |
5076 KB |
Output is correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
4 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5108 KB |
Output is correct |
22 |
Correct |
67 ms |
10124 KB |
Output is correct |
23 |
Correct |
57 ms |
9872 KB |
Output is correct |
24 |
Correct |
46 ms |
9464 KB |
Output is correct |
25 |
Correct |
57 ms |
11008 KB |
Output is correct |
26 |
Correct |
43 ms |
11144 KB |
Output is correct |
27 |
Correct |
3 ms |
5076 KB |
Output is correct |
28 |
Correct |
3 ms |
5040 KB |
Output is correct |
29 |
Correct |
4 ms |
5036 KB |
Output is correct |
30 |
Correct |
3 ms |
5076 KB |
Output is correct |
31 |
Correct |
6 ms |
5168 KB |
Output is correct |
32 |
Correct |
4 ms |
5076 KB |
Output is correct |
33 |
Correct |
4 ms |
5188 KB |
Output is correct |
34 |
Correct |
85 ms |
10552 KB |
Output is correct |
35 |
Correct |
76 ms |
10904 KB |
Output is correct |
36 |
Correct |
83 ms |
11196 KB |
Output is correct |
37 |
Correct |
80 ms |
10992 KB |
Output is correct |
38 |
Correct |
60 ms |
11184 KB |
Output is correct |
39 |
Correct |
34 ms |
9000 KB |
Output is correct |
40 |
Correct |
5 ms |
5240 KB |
Output is correct |
41 |
Correct |
6 ms |
5304 KB |
Output is correct |
42 |
Correct |
5 ms |
5204 KB |
Output is correct |
43 |
Correct |
6 ms |
5204 KB |
Output is correct |
44 |
Correct |
111 ms |
11576 KB |
Output is correct |
45 |
Correct |
133 ms |
11216 KB |
Output is correct |
46 |
Correct |
107 ms |
11476 KB |
Output is correct |
47 |
Correct |
104 ms |
11380 KB |
Output is correct |
48 |
Correct |
71 ms |
11392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5036 KB |
Output is correct |
2 |
Correct |
4 ms |
5040 KB |
Output is correct |
3 |
Correct |
4 ms |
4968 KB |
Output is correct |
4 |
Correct |
5 ms |
5080 KB |
Output is correct |
5 |
Correct |
4 ms |
5088 KB |
Output is correct |
6 |
Correct |
3 ms |
5076 KB |
Output is correct |
7 |
Correct |
3 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
5000 KB |
Output is correct |
9 |
Correct |
4 ms |
5076 KB |
Output is correct |
10 |
Correct |
4 ms |
5036 KB |
Output is correct |
11 |
Correct |
3 ms |
5076 KB |
Output is correct |
12 |
Correct |
5 ms |
5076 KB |
Output is correct |
13 |
Correct |
4 ms |
5076 KB |
Output is correct |
14 |
Correct |
3 ms |
5076 KB |
Output is correct |
15 |
Correct |
3 ms |
5076 KB |
Output is correct |
16 |
Correct |
5 ms |
5044 KB |
Output is correct |
17 |
Correct |
4 ms |
5076 KB |
Output is correct |
18 |
Correct |
4 ms |
5036 KB |
Output is correct |
19 |
Correct |
4 ms |
5036 KB |
Output is correct |
20 |
Correct |
4 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5040 KB |
Output is correct |
23 |
Correct |
4 ms |
5076 KB |
Output is correct |
24 |
Correct |
4 ms |
5076 KB |
Output is correct |
25 |
Correct |
3 ms |
5076 KB |
Output is correct |
26 |
Correct |
7 ms |
5428 KB |
Output is correct |
27 |
Correct |
8 ms |
5332 KB |
Output is correct |
28 |
Correct |
6 ms |
5332 KB |
Output is correct |
29 |
Correct |
6 ms |
5332 KB |
Output is correct |
30 |
Correct |
6 ms |
5156 KB |
Output is correct |
31 |
Correct |
6 ms |
5204 KB |
Output is correct |
32 |
Correct |
5 ms |
5204 KB |
Output is correct |
33 |
Correct |
6 ms |
5308 KB |
Output is correct |
34 |
Correct |
7 ms |
5348 KB |
Output is correct |
35 |
Correct |
4 ms |
5076 KB |
Output is correct |
36 |
Correct |
4 ms |
5076 KB |
Output is correct |
37 |
Correct |
5 ms |
5204 KB |
Output is correct |
38 |
Correct |
7 ms |
5204 KB |
Output is correct |
39 |
Correct |
4 ms |
5076 KB |
Output is correct |
40 |
Correct |
3 ms |
5076 KB |
Output is correct |
41 |
Correct |
3 ms |
5076 KB |
Output is correct |
42 |
Correct |
3 ms |
5076 KB |
Output is correct |
43 |
Correct |
3 ms |
5076 KB |
Output is correct |
44 |
Correct |
3 ms |
5076 KB |
Output is correct |
45 |
Correct |
3 ms |
5076 KB |
Output is correct |
46 |
Correct |
3 ms |
5076 KB |
Output is correct |
47 |
Correct |
3 ms |
5076 KB |
Output is correct |
48 |
Correct |
3 ms |
5076 KB |
Output is correct |
49 |
Correct |
5 ms |
5032 KB |
Output is correct |
50 |
Correct |
49 ms |
10296 KB |
Output is correct |
51 |
Correct |
37 ms |
8864 KB |
Output is correct |
52 |
Correct |
35 ms |
9620 KB |
Output is correct |
53 |
Correct |
50 ms |
11052 KB |
Output is correct |
54 |
Correct |
50 ms |
10600 KB |
Output is correct |
55 |
Correct |
44 ms |
10832 KB |
Output is correct |
56 |
Correct |
3 ms |
5032 KB |
Output is correct |
57 |
Correct |
3 ms |
5076 KB |
Output is correct |
58 |
Correct |
3 ms |
5076 KB |
Output is correct |
59 |
Correct |
4 ms |
5076 KB |
Output is correct |
60 |
Correct |
4 ms |
5108 KB |
Output is correct |
61 |
Correct |
67 ms |
10124 KB |
Output is correct |
62 |
Correct |
57 ms |
9872 KB |
Output is correct |
63 |
Correct |
46 ms |
9464 KB |
Output is correct |
64 |
Correct |
57 ms |
11008 KB |
Output is correct |
65 |
Correct |
43 ms |
11144 KB |
Output is correct |
66 |
Correct |
3 ms |
5076 KB |
Output is correct |
67 |
Correct |
3 ms |
5040 KB |
Output is correct |
68 |
Correct |
4 ms |
5036 KB |
Output is correct |
69 |
Correct |
3 ms |
5076 KB |
Output is correct |
70 |
Correct |
6 ms |
5168 KB |
Output is correct |
71 |
Correct |
4 ms |
5076 KB |
Output is correct |
72 |
Correct |
4 ms |
5188 KB |
Output is correct |
73 |
Correct |
85 ms |
10552 KB |
Output is correct |
74 |
Correct |
76 ms |
10904 KB |
Output is correct |
75 |
Correct |
83 ms |
11196 KB |
Output is correct |
76 |
Correct |
80 ms |
10992 KB |
Output is correct |
77 |
Correct |
60 ms |
11184 KB |
Output is correct |
78 |
Correct |
34 ms |
9000 KB |
Output is correct |
79 |
Correct |
5 ms |
5240 KB |
Output is correct |
80 |
Correct |
6 ms |
5304 KB |
Output is correct |
81 |
Correct |
5 ms |
5204 KB |
Output is correct |
82 |
Correct |
6 ms |
5204 KB |
Output is correct |
83 |
Correct |
111 ms |
11576 KB |
Output is correct |
84 |
Correct |
133 ms |
11216 KB |
Output is correct |
85 |
Correct |
107 ms |
11476 KB |
Output is correct |
86 |
Correct |
104 ms |
11380 KB |
Output is correct |
87 |
Correct |
71 ms |
11392 KB |
Output is correct |
88 |
Correct |
190 ms |
15232 KB |
Output is correct |
89 |
Correct |
175 ms |
12856 KB |
Output is correct |
90 |
Correct |
195 ms |
13184 KB |
Output is correct |
91 |
Correct |
162 ms |
12532 KB |
Output is correct |
92 |
Correct |
149 ms |
11768 KB |
Output is correct |
93 |
Correct |
174 ms |
12980 KB |
Output is correct |
94 |
Correct |
146 ms |
12144 KB |
Output is correct |
95 |
Correct |
101 ms |
11592 KB |
Output is correct |
96 |
Correct |
180 ms |
15148 KB |
Output is correct |
97 |
Correct |
60 ms |
11524 KB |
Output is correct |
98 |
Correct |
74 ms |
11996 KB |
Output is correct |
99 |
Correct |
102 ms |
12008 KB |
Output is correct |