Submission #955306

# Submission time Handle Problem Language Result Execution time Memory
955306 2024-03-30T05:47:16 Z LCJLY Team Contest (JOI22_team) C++14
27 / 100
93 ms 14372 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

void solve(){
	int n;
	cin >> n;
	array<int,3> arr[n];
	for(int x=0;x<n;x++){
		cin >> arr[x][0] >> arr[x][1] >> arr[x][2];
	}
	
	sort(arr,arr+n);
	reverse(arr,arr+n);
	int best=-1;
	priority_queue<pii>pq,pq2;
	bool done[n+5];
	memset(done,0,sizeof(done));
	for(int x=0;x<n;x++){
		pq.push({arr[x][1],x});
		pq2.push({arr[x][2],x});
	}
	
	//for(int x=0;x<n;x++){
		//cout << arr[x][0] << " " << arr[x][1] << " " << arr[x][2] << endl;
	//}
	
	int ptr=0;
	for(int x=0;x<n;x++){
		while(ptr<n&&arr[ptr][0]>=arr[x][0]){
			done[ptr]=true;
			ptr++;
		}
		pii cur={-1,-1};
		pii cur2={-1,-1};
		while(!pq.empty()){
			cur=pq.top();
			if(!done[cur.second]&&!pq2.empty()&&arr[cur.second][2]==pq2.top().first){
				done[cur.second]=true;
			}
			else if(!done[cur.second]){
				break;
			}
			pq.pop();
			cur={-1,-1};
		}
		while(!pq2.empty()){
			cur2=pq2.top();
			if(!done[cur2.second]&&!pq.empty()&&arr[cur2.second][1]==pq.top().first){
				done[cur2.second]=true;
			}
			else if(!done[cur2.second]){
				break;
			}
			pq2.pop();
			cur2={-1,-1};
		}
		cur={-1,-1};
		cur2={-1,-1};
		while(!pq.empty()&&done[pq.top().second]) pq.pop();
		while(!pq2.empty()&&done[pq2.top().second]) pq2.pop();
		
		if(!pq.empty()) cur=pq.top();
		if(!pq2.empty()) cur2=pq2.top();
		
		//show2(cur.first,cur.first,cur2.first,cur2.first);
		//show2(cur.second,cur.second,cur2.second,cur2.second);
		if(cur.second==cur2.second) continue;
		if(cur.first>arr[x][1]&&cur2.first>arr[x][2]){
			best=max(best,arr[x][0]+cur.first+cur2.first);
		}	
		//show4(done,done);
	}
	cout << best;
}	
 
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 65 ms 11496 KB Output is correct
12 Correct 42 ms 6084 KB Output is correct
13 Correct 49 ms 7352 KB Output is correct
14 Correct 73 ms 12212 KB Output is correct
15 Correct 67 ms 11956 KB Output is correct
16 Correct 57 ms 11440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 65 ms 11496 KB Output is correct
12 Correct 42 ms 6084 KB Output is correct
13 Correct 49 ms 7352 KB Output is correct
14 Correct 73 ms 12212 KB Output is correct
15 Correct 67 ms 11956 KB Output is correct
16 Correct 57 ms 11440 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 81 ms 13524 KB Output is correct
23 Correct 68 ms 11136 KB Output is correct
24 Correct 53 ms 6724 KB Output is correct
25 Correct 70 ms 12220 KB Output is correct
26 Correct 61 ms 12120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 65 ms 11496 KB Output is correct
12 Correct 42 ms 6084 KB Output is correct
13 Correct 49 ms 7352 KB Output is correct
14 Correct 73 ms 12212 KB Output is correct
15 Correct 67 ms 11956 KB Output is correct
16 Correct 57 ms 11440 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 81 ms 13524 KB Output is correct
23 Correct 68 ms 11136 KB Output is correct
24 Correct 53 ms 6724 KB Output is correct
25 Correct 70 ms 12220 KB Output is correct
26 Correct 61 ms 12120 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 456 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 82 ms 14372 KB Output is correct
35 Correct 82 ms 12320 KB Output is correct
36 Correct 93 ms 14288 KB Output is correct
37 Correct 90 ms 14164 KB Output is correct
38 Correct 66 ms 13708 KB Output is correct
39 Correct 39 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 65 ms 11496 KB Output is correct
12 Correct 42 ms 6084 KB Output is correct
13 Correct 49 ms 7352 KB Output is correct
14 Correct 73 ms 12212 KB Output is correct
15 Correct 67 ms 11956 KB Output is correct
16 Correct 57 ms 11440 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 81 ms 13524 KB Output is correct
23 Correct 68 ms 11136 KB Output is correct
24 Correct 53 ms 6724 KB Output is correct
25 Correct 70 ms 12220 KB Output is correct
26 Correct 61 ms 12120 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 456 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 82 ms 14372 KB Output is correct
35 Correct 82 ms 12320 KB Output is correct
36 Correct 93 ms 14288 KB Output is correct
37 Correct 90 ms 14164 KB Output is correct
38 Correct 66 ms 13708 KB Output is correct
39 Correct 39 ms 6736 KB Output is correct
40 Incorrect 2 ms 600 KB Output isn't correct
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -