답안 #697561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697561 2023-02-10T11:31:03 Z emptypringlescan Team Contest (JOI22_team) C++17
46 / 100
62 ms 8780 KB
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<pair<int,int>,pair<int,int> > a,pair<pair<int,int>,pair<int,int> > b){
	return a.first.second>b.first.second;
}
bool cmp2(pair<pair<int,int>,pair<int,int> > a,pair<pair<int,int>,pair<int,int> > b){
	return a.second.first>b.second.first;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	pair<pair<int,int>,pair<int,int> > tp[n],tp2[n],tp3[n];
	for(int i=0; i<n; i++){
		int a,b,c;
		cin >> a >> b >> c;
		tp[i]=tp2[i]=tp3[i]={{a,b},{c,i}};
	}
	sort(tp,tp+n,greater<pair<pair<int,int>,pair<int,int> > >());
	sort(tp2,tp2+n,cmp);
	sort(tp3,tp3+n,cmp2);
	int c1=0,c2=0,c3=0,del[n];
	memset(del,0,sizeof(del));
	while(true){
		if(c1>=n||c2>=n||c3>=n) break;
		while(c1<n&&del[tp[c1].second.second]){
			c1++;
		}
		while(c2<n&&del[tp2[c2].second.second]){
			c2++;
		}
		while(c3<n&&del[tp3[c3].second.second]){
			c3++;
		}/*
		cout << c1 << ' ' << c2 << ' ' << c3 << '\n';
		cout << tp[c1].first.first << ' ' << tp[c1].first.second << ' ' << tp[c1].second.first << "   ";
		cout << tp2[c2].first.first << ' ' << tp2[c2].first.second << ' ' << tp2[c2].second.first << "   ";
		cout << tp3[c3].first.first << ' ' << tp3[c3].first.second << ' ' << tp3[c3].second.first << "   ";
		cout << "\n";*/
		if(tp2[c2].first.first>=tp[c1].first.first){
			del[tp2[c2].second.second]=1;
			c2++;
			continue;
		}
		if(tp3[c3].first.first>=tp[c1].first.first){
			del[tp3[c3].second.second]=1;
			c3++;
			continue;
		}
		if(tp[c1].first.second>=tp2[c2].first.second){
			del[tp[c1].second.second]=1;
			c1++;
			continue;
		}
		if(tp3[c3].first.second>=tp2[c2].first.second){
			del[tp3[c3].second.second]=1;
			c3++;
			continue;
		}
		if(tp2[c2].second.first>=tp3[c3].second.first){
			del[tp2[c2].second.second]=1;
			c2++;
			continue;
		}
		if(tp[c1].second.first>=tp3[c3].second.first){
			del[tp[c1].second.second]=1;
			c1++;
			continue;
		}
		cout << tp[c1].first.first+tp2[c2].first.second+tp3[c3].second.first;
		return 0;
	}
	cout << -1;
}

# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 3 ms 596 KB Output is correct
27 Correct 3 ms 580 KB Output is correct
28 Correct 3 ms 596 KB Output is correct
29 Correct 3 ms 608 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 3 ms 456 KB Output is correct
32 Correct 2 ms 548 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 2 ms 596 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 3 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 328 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 62 ms 8748 KB Output is correct
12 Correct 44 ms 5976 KB Output is correct
13 Correct 43 ms 7244 KB Output is correct
14 Correct 60 ms 8748 KB Output is correct
15 Correct 56 ms 8748 KB Output is correct
16 Correct 45 ms 8780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 328 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 62 ms 8748 KB Output is correct
12 Correct 44 ms 5976 KB Output is correct
13 Correct 43 ms 7244 KB Output is correct
14 Correct 60 ms 8748 KB Output is correct
15 Correct 56 ms 8748 KB Output is correct
16 Correct 45 ms 8780 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Runtime error 1 ms 340 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 328 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 62 ms 8748 KB Output is correct
12 Correct 44 ms 5976 KB Output is correct
13 Correct 43 ms 7244 KB Output is correct
14 Correct 60 ms 8748 KB Output is correct
15 Correct 56 ms 8748 KB Output is correct
16 Correct 45 ms 8780 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Runtime error 1 ms 340 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 328 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 62 ms 8748 KB Output is correct
12 Correct 44 ms 5976 KB Output is correct
13 Correct 43 ms 7244 KB Output is correct
14 Correct 60 ms 8748 KB Output is correct
15 Correct 56 ms 8748 KB Output is correct
16 Correct 45 ms 8780 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Runtime error 1 ms 340 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 3 ms 596 KB Output is correct
27 Correct 3 ms 580 KB Output is correct
28 Correct 3 ms 596 KB Output is correct
29 Correct 3 ms 608 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 3 ms 456 KB Output is correct
32 Correct 2 ms 548 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 2 ms 596 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 3 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 316 KB Output is correct
44 Correct 1 ms 328 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 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 62 ms 8748 KB Output is correct
51 Correct 44 ms 5976 KB Output is correct
52 Correct 43 ms 7244 KB Output is correct
53 Correct 60 ms 8748 KB Output is correct
54 Correct 56 ms 8748 KB Output is correct
55 Correct 45 ms 8780 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Runtime error 1 ms 340 KB Execution killed with signal 11
59 Halted 0 ms 0 KB -