Submission #713865

# Submission time Handle Problem Language Result Execution time Memory
713865 2023-03-23T06:31:09 Z 089487 Team Contest (JOI22_team) C++14
64 / 100
2000 ms 10944 KB
#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;
	}
	
	rep(i,1,sz(vx)){
		for(pii p2:v[i]){
			rep(yi,p2.F+1,sz(vy)){
				int pz=max(p2.S,yz[yi]);
				int q=qry(yi-1);
				if(q>pz){
					ans=max(ans,vx[i-1]+vy[yi-1]+vz[q-1]);
				}
			}
		}
		for(pii p2:v[i]){
			yz[p2.F]=min(yz[p2.F],p2.S);
			upd(p2.F,p2.S);
		}
	}
	cout<<ans<<"\n";

	return 0;
}
# 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 3 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 3 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
16 Correct 4 ms 5072 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 4 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 3 ms 5076 KB Output is correct
24 Correct 3 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 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 3 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 3 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
16 Correct 4 ms 5072 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 4 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 3 ms 5076 KB Output is correct
24 Correct 3 ms 5076 KB Output is correct
25 Correct 3 ms 5076 KB Output is correct
26 Correct 99 ms 5308 KB Output is correct
27 Correct 54 ms 5260 KB Output is correct
28 Correct 46 ms 5204 KB Output is correct
29 Correct 36 ms 5324 KB Output is correct
30 Correct 23 ms 5228 KB Output is correct
31 Correct 27 ms 5252 KB Output is correct
32 Correct 7 ms 5204 KB Output is correct
33 Correct 7 ms 5204 KB Output is correct
34 Correct 75 ms 5320 KB Output is correct
35 Correct 4 ms 5076 KB Output is correct
36 Correct 4 ms 5076 KB Output is correct
37 Correct 24 ms 5252 KB Output is correct
38 Correct 25 ms 5252 KB Output is correct
39 Correct 4 ms 5100 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 4948 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 51 ms 10164 KB Output is correct
12 Correct 32 ms 8812 KB Output is correct
13 Correct 34 ms 9512 KB Output is correct
14 Correct 47 ms 10944 KB Output is correct
15 Correct 43 ms 10500 KB Output is correct
16 Correct 37 ms 10784 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 4948 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 51 ms 10164 KB Output is correct
12 Correct 32 ms 8812 KB Output is correct
13 Correct 34 ms 9512 KB Output is correct
14 Correct 47 ms 10944 KB Output is correct
15 Correct 43 ms 10500 KB Output is correct
16 Correct 37 ms 10784 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 69 ms 9968 KB Output is correct
23 Correct 62 ms 9824 KB Output is correct
24 Correct 45 ms 8736 KB Output is correct
25 Correct 60 ms 10336 KB Output is correct
26 Correct 47 ms 10512 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 4948 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 51 ms 10164 KB Output is correct
12 Correct 32 ms 8812 KB Output is correct
13 Correct 34 ms 9512 KB Output is correct
14 Correct 47 ms 10944 KB Output is correct
15 Correct 43 ms 10500 KB Output is correct
16 Correct 37 ms 10784 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 69 ms 9968 KB Output is correct
23 Correct 62 ms 9824 KB Output is correct
24 Correct 45 ms 8736 KB Output is correct
25 Correct 60 ms 10336 KB Output is correct
26 Correct 47 ms 10512 KB Output is correct
27 Correct 4 ms 5076 KB Output is correct
28 Correct 3 ms 5076 KB Output is correct
29 Correct 4 ms 5076 KB Output is correct
30 Correct 3 ms 5076 KB Output is correct
31 Correct 10 ms 5204 KB Output is correct
32 Correct 4 ms 5120 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 192 ms 9816 KB Output is correct
35 Correct 198 ms 10220 KB Output is correct
36 Correct 218 ms 10452 KB Output is correct
37 Correct 152 ms 10224 KB Output is correct
38 Correct 72 ms 10352 KB Output is correct
39 Correct 98 ms 8320 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 4948 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 51 ms 10164 KB Output is correct
12 Correct 32 ms 8812 KB Output is correct
13 Correct 34 ms 9512 KB Output is correct
14 Correct 47 ms 10944 KB Output is correct
15 Correct 43 ms 10500 KB Output is correct
16 Correct 37 ms 10784 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 69 ms 9968 KB Output is correct
23 Correct 62 ms 9824 KB Output is correct
24 Correct 45 ms 8736 KB Output is correct
25 Correct 60 ms 10336 KB Output is correct
26 Correct 47 ms 10512 KB Output is correct
27 Correct 4 ms 5076 KB Output is correct
28 Correct 3 ms 5076 KB Output is correct
29 Correct 4 ms 5076 KB Output is correct
30 Correct 3 ms 5076 KB Output is correct
31 Correct 10 ms 5204 KB Output is correct
32 Correct 4 ms 5120 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 192 ms 9816 KB Output is correct
35 Correct 198 ms 10220 KB Output is correct
36 Correct 218 ms 10452 KB Output is correct
37 Correct 152 ms 10224 KB Output is correct
38 Correct 72 ms 10352 KB Output is correct
39 Correct 98 ms 8320 KB Output is correct
40 Correct 20 ms 5204 KB Output is correct
41 Correct 26 ms 5204 KB Output is correct
42 Correct 22 ms 5204 KB Output is correct
43 Correct 23 ms 5228 KB Output is correct
44 Execution timed out 2098 ms 10664 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# 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 3 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 3 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
16 Correct 4 ms 5072 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 4 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 3 ms 5076 KB Output is correct
24 Correct 3 ms 5076 KB Output is correct
25 Correct 3 ms 5076 KB Output is correct
26 Correct 99 ms 5308 KB Output is correct
27 Correct 54 ms 5260 KB Output is correct
28 Correct 46 ms 5204 KB Output is correct
29 Correct 36 ms 5324 KB Output is correct
30 Correct 23 ms 5228 KB Output is correct
31 Correct 27 ms 5252 KB Output is correct
32 Correct 7 ms 5204 KB Output is correct
33 Correct 7 ms 5204 KB Output is correct
34 Correct 75 ms 5320 KB Output is correct
35 Correct 4 ms 5076 KB Output is correct
36 Correct 4 ms 5076 KB Output is correct
37 Correct 24 ms 5252 KB Output is correct
38 Correct 25 ms 5252 KB Output is correct
39 Correct 4 ms 5100 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 4948 KB Output is correct
48 Correct 3 ms 5076 KB Output is correct
49 Correct 3 ms 5076 KB Output is correct
50 Correct 51 ms 10164 KB Output is correct
51 Correct 32 ms 8812 KB Output is correct
52 Correct 34 ms 9512 KB Output is correct
53 Correct 47 ms 10944 KB Output is correct
54 Correct 43 ms 10500 KB Output is correct
55 Correct 37 ms 10784 KB Output is correct
56 Correct 3 ms 5076 KB Output is correct
57 Correct 3 ms 5076 KB Output is correct
58 Correct 3 ms 5076 KB Output is correct
59 Correct 3 ms 5076 KB Output is correct
60 Correct 4 ms 5076 KB Output is correct
61 Correct 69 ms 9968 KB Output is correct
62 Correct 62 ms 9824 KB Output is correct
63 Correct 45 ms 8736 KB Output is correct
64 Correct 60 ms 10336 KB Output is correct
65 Correct 47 ms 10512 KB Output is correct
66 Correct 4 ms 5076 KB Output is correct
67 Correct 3 ms 5076 KB Output is correct
68 Correct 4 ms 5076 KB Output is correct
69 Correct 3 ms 5076 KB Output is correct
70 Correct 10 ms 5204 KB Output is correct
71 Correct 4 ms 5120 KB Output is correct
72 Correct 5 ms 5076 KB Output is correct
73 Correct 192 ms 9816 KB Output is correct
74 Correct 198 ms 10220 KB Output is correct
75 Correct 218 ms 10452 KB Output is correct
76 Correct 152 ms 10224 KB Output is correct
77 Correct 72 ms 10352 KB Output is correct
78 Correct 98 ms 8320 KB Output is correct
79 Correct 20 ms 5204 KB Output is correct
80 Correct 26 ms 5204 KB Output is correct
81 Correct 22 ms 5204 KB Output is correct
82 Correct 23 ms 5228 KB Output is correct
83 Execution timed out 2098 ms 10664 KB Time limit exceeded
84 Halted 0 ms 0 KB -