답안 #777022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777022 2023-07-08T13:54:24 Z aZvezda Team Contest (JOI22_team) C++14
100 / 100
287 ms 21828 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const ll MAX_N = 2e5 + 10;
ll n;
pair<ll, ll> a[MAX_N], b[MAX_N], c[MAX_N];
pair<ll, pair<ll, ll> > p[MAX_N];

signed main() {
	cin >> n;
	for(ll i = 0; i < n; i ++) {
		cin >> p[i].first >> p[i].second.first >> p[i].second.second;
		a[i] = {p[i].first, i};
		b[i] = {p[i].second.first, i};
		c[i] = {p[i].second.second, i};
	}

	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);

	ll pa = n - 1, pb = n - 1, pc = n - 1;

	ll ans = -1;
	set<ll> st;

	while(true) {
		if(min({pa, pb, pc}) == -1) { break; }

		if(st.find(a[pa].second) != st.end()) { pa --; continue; }	
		if(st.find(b[pb].second) != st.end()) { pb --; continue; }	
		if(st.find(c[pc].second) != st.end()) { pc --; continue; }	

		if(a[pa].second == b[pb].second || a[pa].second == c[pc].second) { st.insert(a[pa].second); pa --; continue; }
		if(b[pb].second == c[pc].second) { st.insert(b[pb].second); pb --; continue; }
		
		if(p[a[pa].second].second.first >= b[pb].first) {
			st.insert(a[pa].second);
			pa --;
			continue;
		}
		if(p[a[pa].second].second.second >= c[pc].first) {
			st.insert(a[pa].second);
			pa --;
			continue;
		}
		if(p[b[pb].second].first >= a[pa].first) {
			st.insert(b[pb].second);
			pb --;
			continue;
		}
		if(p[b[pb].second].second.second >= c[pc].first) {
			st.insert(b[pb].second);
			pb --;
			continue;
		}
		if(p[c[pc].second].first >= a[pa].first) {
			st.insert(c[pc].second);
			pc --;
			continue;
		}
		if(p[c[pc].second].second.first >= b[pb].first) {
			st.insert(c[pc].second);
			pc --;
			continue;
		}
		ans = max(ans, a[pa].first + b[pb].first + c[pc].first);
		break;
	}

	cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 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 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 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 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 4 ms 596 KB Output is correct
27 Correct 4 ms 596 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 7 ms 736 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 5 ms 724 KB Output is correct
34 Correct 6 ms 792 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 4 ms 724 KB Output is correct
39 Correct 2 ms 468 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 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 0 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 87 ms 10956 KB Output is correct
12 Correct 81 ms 11356 KB Output is correct
13 Correct 71 ms 10316 KB Output is correct
14 Correct 177 ms 18772 KB Output is correct
15 Correct 180 ms 18684 KB Output is correct
16 Correct 167 ms 18680 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 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 0 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 87 ms 10956 KB Output is correct
12 Correct 81 ms 11356 KB Output is correct
13 Correct 71 ms 10316 KB Output is correct
14 Correct 177 ms 18772 KB Output is correct
15 Correct 180 ms 18684 KB Output is correct
16 Correct 167 ms 18680 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 452 KB Output is correct
22 Correct 97 ms 11984 KB Output is correct
23 Correct 99 ms 12804 KB Output is correct
24 Correct 103 ms 12448 KB Output is correct
25 Correct 154 ms 18928 KB Output is correct
26 Correct 185 ms 18908 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 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 0 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 87 ms 10956 KB Output is correct
12 Correct 81 ms 11356 KB Output is correct
13 Correct 71 ms 10316 KB Output is correct
14 Correct 177 ms 18772 KB Output is correct
15 Correct 180 ms 18684 KB Output is correct
16 Correct 167 ms 18680 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 452 KB Output is correct
22 Correct 97 ms 11984 KB Output is correct
23 Correct 99 ms 12804 KB Output is correct
24 Correct 103 ms 12448 KB Output is correct
25 Correct 154 ms 18928 KB Output is correct
26 Correct 185 ms 18908 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 4 ms 828 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 101 ms 11792 KB Output is correct
35 Correct 117 ms 13672 KB Output is correct
36 Correct 159 ms 15084 KB Output is correct
37 Correct 200 ms 19488 KB Output is correct
38 Correct 192 ms 19020 KB Output is correct
39 Correct 118 ms 11788 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 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 0 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 87 ms 10956 KB Output is correct
12 Correct 81 ms 11356 KB Output is correct
13 Correct 71 ms 10316 KB Output is correct
14 Correct 177 ms 18772 KB Output is correct
15 Correct 180 ms 18684 KB Output is correct
16 Correct 167 ms 18680 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 452 KB Output is correct
22 Correct 97 ms 11984 KB Output is correct
23 Correct 99 ms 12804 KB Output is correct
24 Correct 103 ms 12448 KB Output is correct
25 Correct 154 ms 18928 KB Output is correct
26 Correct 185 ms 18908 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 4 ms 828 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 101 ms 11792 KB Output is correct
35 Correct 117 ms 13672 KB Output is correct
36 Correct 159 ms 15084 KB Output is correct
37 Correct 200 ms 19488 KB Output is correct
38 Correct 192 ms 19020 KB Output is correct
39 Correct 118 ms 11788 KB Output is correct
40 Correct 4 ms 576 KB Output is correct
41 Correct 3 ms 596 KB Output is correct
42 Correct 3 ms 596 KB Output is correct
43 Correct 4 ms 760 KB Output is correct
44 Correct 118 ms 12932 KB Output is correct
45 Correct 195 ms 19428 KB Output is correct
46 Correct 173 ms 17524 KB Output is correct
47 Correct 230 ms 20128 KB Output is correct
48 Correct 211 ms 19924 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 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 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 4 ms 596 KB Output is correct
27 Correct 4 ms 596 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 7 ms 736 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 5 ms 724 KB Output is correct
34 Correct 6 ms 792 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 4 ms 724 KB Output is correct
39 Correct 2 ms 468 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 1 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 0 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 87 ms 10956 KB Output is correct
51 Correct 81 ms 11356 KB Output is correct
52 Correct 71 ms 10316 KB Output is correct
53 Correct 177 ms 18772 KB Output is correct
54 Correct 180 ms 18684 KB Output is correct
55 Correct 167 ms 18680 KB Output is correct
56 Correct 0 ms 308 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 2 ms 452 KB Output is correct
61 Correct 97 ms 11984 KB Output is correct
62 Correct 99 ms 12804 KB Output is correct
63 Correct 103 ms 12448 KB Output is correct
64 Correct 154 ms 18928 KB Output is correct
65 Correct 185 ms 18908 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 4 ms 828 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 101 ms 11792 KB Output is correct
74 Correct 117 ms 13672 KB Output is correct
75 Correct 159 ms 15084 KB Output is correct
76 Correct 200 ms 19488 KB Output is correct
77 Correct 192 ms 19020 KB Output is correct
78 Correct 118 ms 11788 KB Output is correct
79 Correct 4 ms 576 KB Output is correct
80 Correct 3 ms 596 KB Output is correct
81 Correct 3 ms 596 KB Output is correct
82 Correct 4 ms 760 KB Output is correct
83 Correct 118 ms 12932 KB Output is correct
84 Correct 195 ms 19428 KB Output is correct
85 Correct 173 ms 17524 KB Output is correct
86 Correct 230 ms 20128 KB Output is correct
87 Correct 211 ms 19924 KB Output is correct
88 Correct 149 ms 14700 KB Output is correct
89 Correct 216 ms 19000 KB Output is correct
90 Correct 155 ms 15280 KB Output is correct
91 Correct 282 ms 21676 KB Output is correct
92 Correct 158 ms 15360 KB Output is correct
93 Correct 213 ms 19208 KB Output is correct
94 Correct 232 ms 20508 KB Output is correct
95 Correct 248 ms 21696 KB Output is correct
96 Correct 287 ms 21828 KB Output is correct
97 Correct 232 ms 21756 KB Output is correct
98 Correct 96 ms 13388 KB Output is correct
99 Correct 267 ms 20428 KB Output is correct