답안 #697562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697562 2023-02-10T11:32:23 Z emptypringlescan Team Contest (JOI22_team) C++17
100 / 100
97 ms 11812 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){
		
		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++;
		}
		if(c1>=n||c2>=n||c3>=n) break;/*
		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 0 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 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 2 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 60 ms 7864 KB Output is correct
12 Correct 40 ms 5324 KB Output is correct
13 Correct 41 ms 6480 KB Output is correct
14 Correct 60 ms 7932 KB Output is correct
15 Correct 57 ms 7868 KB Output is correct
16 Correct 44 ms 7856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 60 ms 7864 KB Output is correct
12 Correct 40 ms 5324 KB Output is correct
13 Correct 41 ms 6480 KB Output is correct
14 Correct 60 ms 7932 KB Output is correct
15 Correct 57 ms 7868 KB Output is correct
16 Correct 44 ms 7856 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 324 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 66 ms 8980 KB Output is correct
23 Correct 72 ms 8612 KB Output is correct
24 Correct 48 ms 6540 KB Output is correct
25 Correct 66 ms 8984 KB Output is correct
26 Correct 57 ms 8844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 60 ms 7864 KB Output is correct
12 Correct 40 ms 5324 KB Output is correct
13 Correct 41 ms 6480 KB Output is correct
14 Correct 60 ms 7932 KB Output is correct
15 Correct 57 ms 7868 KB Output is correct
16 Correct 44 ms 7856 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 324 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 66 ms 8980 KB Output is correct
23 Correct 72 ms 8612 KB Output is correct
24 Correct 48 ms 6540 KB Output is correct
25 Correct 66 ms 8984 KB Output is correct
26 Correct 57 ms 8844 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 68 ms 9032 KB Output is correct
35 Correct 66 ms 8524 KB Output is correct
36 Correct 69 ms 9388 KB Output is correct
37 Correct 70 ms 9436 KB Output is correct
38 Correct 63 ms 9228 KB Output is correct
39 Correct 38 ms 5784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 60 ms 7864 KB Output is correct
12 Correct 40 ms 5324 KB Output is correct
13 Correct 41 ms 6480 KB Output is correct
14 Correct 60 ms 7932 KB Output is correct
15 Correct 57 ms 7868 KB Output is correct
16 Correct 44 ms 7856 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 324 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 66 ms 8980 KB Output is correct
23 Correct 72 ms 8612 KB Output is correct
24 Correct 48 ms 6540 KB Output is correct
25 Correct 66 ms 8984 KB Output is correct
26 Correct 57 ms 8844 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 68 ms 9032 KB Output is correct
35 Correct 66 ms 8524 KB Output is correct
36 Correct 69 ms 9388 KB Output is correct
37 Correct 70 ms 9436 KB Output is correct
38 Correct 63 ms 9228 KB Output is correct
39 Correct 38 ms 5784 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 456 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 77 ms 9932 KB Output is correct
45 Correct 76 ms 9932 KB Output is correct
46 Correct 83 ms 9884 KB Output is correct
47 Correct 77 ms 10060 KB Output is correct
48 Correct 67 ms 9924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 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 2 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 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 0 ms 212 KB Output is correct
50 Correct 60 ms 7864 KB Output is correct
51 Correct 40 ms 5324 KB Output is correct
52 Correct 41 ms 6480 KB Output is correct
53 Correct 60 ms 7932 KB Output is correct
54 Correct 57 ms 7868 KB Output is correct
55 Correct 44 ms 7856 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 324 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 66 ms 8980 KB Output is correct
62 Correct 72 ms 8612 KB Output is correct
63 Correct 48 ms 6540 KB Output is correct
64 Correct 66 ms 8984 KB Output is correct
65 Correct 57 ms 8844 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 2 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 68 ms 9032 KB Output is correct
74 Correct 66 ms 8524 KB Output is correct
75 Correct 69 ms 9388 KB Output is correct
76 Correct 70 ms 9436 KB Output is correct
77 Correct 63 ms 9228 KB Output is correct
78 Correct 38 ms 5784 KB Output is correct
79 Correct 2 ms 468 KB Output is correct
80 Correct 2 ms 468 KB Output is correct
81 Correct 2 ms 456 KB Output is correct
82 Correct 2 ms 468 KB Output is correct
83 Correct 77 ms 9932 KB Output is correct
84 Correct 76 ms 9932 KB Output is correct
85 Correct 83 ms 9884 KB Output is correct
86 Correct 77 ms 10060 KB Output is correct
87 Correct 67 ms 9924 KB Output is correct
88 Correct 85 ms 11724 KB Output is correct
89 Correct 91 ms 11804 KB Output is correct
90 Correct 95 ms 11808 KB Output is correct
91 Correct 92 ms 11692 KB Output is correct
92 Correct 79 ms 10288 KB Output is correct
93 Correct 84 ms 10664 KB Output is correct
94 Correct 84 ms 10540 KB Output is correct
95 Correct 79 ms 11724 KB Output is correct
96 Correct 87 ms 11812 KB Output is correct
97 Correct 61 ms 11804 KB Output is correct
98 Correct 56 ms 10396 KB Output is correct
99 Correct 97 ms 10368 KB Output is correct