답안 #955302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955302 2024-03-30T05:41:17 Z LCJLY Team Contest (JOI22_team) C++14
18 / 100
78 ms 13236 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.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();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 64 ms 11496 KB Output is correct
12 Correct 41 ms 6216 KB Output is correct
13 Correct 48 ms 7360 KB Output is correct
14 Correct 67 ms 13020 KB Output is correct
15 Correct 62 ms 11200 KB Output is correct
16 Correct 57 ms 12468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 64 ms 11496 KB Output is correct
12 Correct 41 ms 6216 KB Output is correct
13 Correct 48 ms 7360 KB Output is correct
14 Correct 67 ms 13020 KB Output is correct
15 Correct 62 ms 11200 KB Output is correct
16 Correct 57 ms 12468 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 78 ms 12260 KB Output is correct
23 Correct 68 ms 13236 KB Output is correct
24 Correct 50 ms 6592 KB Output is correct
25 Correct 74 ms 12496 KB Output is correct
26 Correct 61 ms 12720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 64 ms 11496 KB Output is correct
12 Correct 41 ms 6216 KB Output is correct
13 Correct 48 ms 7360 KB Output is correct
14 Correct 67 ms 13020 KB Output is correct
15 Correct 62 ms 11200 KB Output is correct
16 Correct 57 ms 12468 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 78 ms 12260 KB Output is correct
23 Correct 68 ms 13236 KB Output is correct
24 Correct 50 ms 6592 KB Output is correct
25 Correct 74 ms 12496 KB Output is correct
26 Correct 61 ms 12720 KB Output is correct
27 Incorrect 1 ms 348 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 64 ms 11496 KB Output is correct
12 Correct 41 ms 6216 KB Output is correct
13 Correct 48 ms 7360 KB Output is correct
14 Correct 67 ms 13020 KB Output is correct
15 Correct 62 ms 11200 KB Output is correct
16 Correct 57 ms 12468 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 78 ms 12260 KB Output is correct
23 Correct 68 ms 13236 KB Output is correct
24 Correct 50 ms 6592 KB Output is correct
25 Correct 74 ms 12496 KB Output is correct
26 Correct 61 ms 12720 KB Output is correct
27 Incorrect 1 ms 348 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -