답안 #782151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782151 2023-07-13T15:43:56 Z adaawf Team Contest (JOI22_team) C++14
100 / 100
302 ms 21836 KB
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
pair<long long int, long long int> a[200005], b[200005], c[200005];
pair<long long int, pair<long long int, long long int>> p[200005];
int main() {
    int n;
	cin >> n;
	for (int i = 1; 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 + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	long long int x = n, y = n, z = n;
	set<long long int> s;
	while (1) {
		if (x == 0 || y == 0 || z == 0) {
            cout << -1;
            return 0;
		}
		if (s.find(a[x].second) != s.end()) {
            x--;
            continue;
        }
		if (s.find(b[y].second) != s.end()) {
            y--;
            continue;
        }
		if (s.find(c[z].second) != s.end()) {
            z--;
            continue;
        }
		if (a[x].second == b[y].second) {
		    s.insert(a[x].second);
            x--;
            continue;
        }
        if (a[x].second == c[z].second) {
            s.insert(a[x].second);
            x--;
            continue;
        }
		if (b[y].second == c[z].second) {
            s.insert(b[y].second);
            y--;
            continue;
        }
		if (p[a[x].second].second.first >= b[y].first) {
			s.insert(a[x].second);
			x--;
			continue;
		}
		if (p[a[x].second].second.second >= c[z].first) {
			s.insert(a[x].second);
			x--;
			continue;
		}
		if (p[b[y].second].first >= a[x].first) {
			s.insert(b[y].second);
			y--;
			continue;
		}
		if (p[b[y].second].second.second >= c[z].first) {
			s.insert(b[y].second);
			y--;
			continue;
		}
		if (p[c[z].second].first >= a[x].first) {
			s.insert(c[z].second);
			z--;
			continue;
		}
		if (p[c[z].second].second.first >= b[y].first) {
			s.insert(c[z].second);
			z--;
			continue;
		}
		cout << a[x].first + b[y].first + c[z].first;
		return 0;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 308 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 340 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 0 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 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 0 ms 340 KB Output is correct
2 Correct 0 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 308 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 340 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 0 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 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 600 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 5 ms 724 KB Output is correct
29 Correct 6 ms 852 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 4 ms 596 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 5 ms 832 KB Output is correct
34 Correct 7 ms 844 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 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 444 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 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 85 ms 11724 KB Output is correct
12 Correct 80 ms 11440 KB Output is correct
13 Correct 68 ms 10364 KB Output is correct
14 Correct 138 ms 18716 KB Output is correct
15 Correct 188 ms 18800 KB Output is correct
16 Correct 168 ms 18692 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 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 85 ms 11724 KB Output is correct
12 Correct 80 ms 11440 KB Output is correct
13 Correct 68 ms 10364 KB Output is correct
14 Correct 138 ms 18716 KB Output is correct
15 Correct 188 ms 18800 KB Output is correct
16 Correct 168 ms 18692 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 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 101 ms 11920 KB Output is correct
23 Correct 99 ms 12856 KB Output is correct
24 Correct 95 ms 12452 KB Output is correct
25 Correct 152 ms 18988 KB Output is correct
26 Correct 186 ms 18896 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 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 85 ms 11724 KB Output is correct
12 Correct 80 ms 11440 KB Output is correct
13 Correct 68 ms 10364 KB Output is correct
14 Correct 138 ms 18716 KB Output is correct
15 Correct 188 ms 18800 KB Output is correct
16 Correct 168 ms 18692 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 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 101 ms 11920 KB Output is correct
23 Correct 99 ms 12856 KB Output is correct
24 Correct 95 ms 12452 KB Output is correct
25 Correct 152 ms 18988 KB Output is correct
26 Correct 186 ms 18896 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 724 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 100 ms 11812 KB Output is correct
35 Correct 123 ms 13668 KB Output is correct
36 Correct 132 ms 15112 KB Output is correct
37 Correct 188 ms 19416 KB Output is correct
38 Correct 193 ms 18940 KB Output is correct
39 Correct 126 ms 11856 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 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 85 ms 11724 KB Output is correct
12 Correct 80 ms 11440 KB Output is correct
13 Correct 68 ms 10364 KB Output is correct
14 Correct 138 ms 18716 KB Output is correct
15 Correct 188 ms 18800 KB Output is correct
16 Correct 168 ms 18692 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 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 101 ms 11920 KB Output is correct
23 Correct 99 ms 12856 KB Output is correct
24 Correct 95 ms 12452 KB Output is correct
25 Correct 152 ms 18988 KB Output is correct
26 Correct 186 ms 18896 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 724 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 100 ms 11812 KB Output is correct
35 Correct 123 ms 13668 KB Output is correct
36 Correct 132 ms 15112 KB Output is correct
37 Correct 188 ms 19416 KB Output is correct
38 Correct 193 ms 18940 KB Output is correct
39 Correct 126 ms 11856 KB Output is correct
40 Correct 3 ms 556 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 840 KB Output is correct
44 Correct 119 ms 12836 KB Output is correct
45 Correct 200 ms 19472 KB Output is correct
46 Correct 195 ms 17536 KB Output is correct
47 Correct 214 ms 20016 KB Output is correct
48 Correct 211 ms 19880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 308 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 340 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 0 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 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 600 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 5 ms 724 KB Output is correct
29 Correct 6 ms 852 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 4 ms 596 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 5 ms 832 KB Output is correct
34 Correct 7 ms 844 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 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 444 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 312 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 85 ms 11724 KB Output is correct
51 Correct 80 ms 11440 KB Output is correct
52 Correct 68 ms 10364 KB Output is correct
53 Correct 138 ms 18716 KB Output is correct
54 Correct 188 ms 18800 KB Output is correct
55 Correct 168 ms 18692 KB Output is correct
56 Correct 1 ms 212 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 304 KB Output is correct
60 Correct 2 ms 468 KB Output is correct
61 Correct 101 ms 11920 KB Output is correct
62 Correct 99 ms 12856 KB Output is correct
63 Correct 95 ms 12452 KB Output is correct
64 Correct 152 ms 18988 KB Output is correct
65 Correct 186 ms 18896 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 724 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 100 ms 11812 KB Output is correct
74 Correct 123 ms 13668 KB Output is correct
75 Correct 132 ms 15112 KB Output is correct
76 Correct 188 ms 19416 KB Output is correct
77 Correct 193 ms 18940 KB Output is correct
78 Correct 126 ms 11856 KB Output is correct
79 Correct 3 ms 556 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 840 KB Output is correct
83 Correct 119 ms 12836 KB Output is correct
84 Correct 200 ms 19472 KB Output is correct
85 Correct 195 ms 17536 KB Output is correct
86 Correct 214 ms 20016 KB Output is correct
87 Correct 211 ms 19880 KB Output is correct
88 Correct 149 ms 14672 KB Output is correct
89 Correct 211 ms 18900 KB Output is correct
90 Correct 157 ms 15256 KB Output is correct
91 Correct 302 ms 21836 KB Output is correct
92 Correct 149 ms 15312 KB Output is correct
93 Correct 211 ms 19192 KB Output is correct
94 Correct 237 ms 20468 KB Output is correct
95 Correct 243 ms 21672 KB Output is correct
96 Correct 269 ms 21816 KB Output is correct
97 Correct 238 ms 21836 KB Output is correct
98 Correct 97 ms 13336 KB Output is correct
99 Correct 236 ms 20444 KB Output is correct