답안 #782153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782153 2023-07-13T15:44:26 Z vjudge1 Team Contest (JOI22_team) C++17
100 / 100
287 ms 17988 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 212 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 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 224 KB Output is correct
10 Correct 1 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 0 ms 212 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 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 224 KB Output is correct
10 Correct 1 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 544 KB Output is correct
27 Correct 4 ms 612 KB Output is correct
28 Correct 7 ms 608 KB Output is correct
29 Correct 6 ms 724 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 724 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 784 KB Output is correct
39 Correct 2 ms 452 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 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 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 87 ms 10824 KB Output is correct
12 Correct 79 ms 10828 KB Output is correct
13 Correct 70 ms 9548 KB Output is correct
14 Correct 146 ms 17916 KB Output is correct
15 Correct 187 ms 17912 KB Output is correct
16 Correct 169 ms 17896 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 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 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 87 ms 10824 KB Output is correct
12 Correct 79 ms 10828 KB Output is correct
13 Correct 70 ms 9548 KB Output is correct
14 Correct 146 ms 17916 KB Output is correct
15 Correct 187 ms 17912 KB Output is correct
16 Correct 169 ms 17896 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 436 KB Output is correct
22 Correct 96 ms 10848 KB Output is correct
23 Correct 98 ms 11876 KB Output is correct
24 Correct 101 ms 11740 KB Output is correct
25 Correct 150 ms 17840 KB Output is correct
26 Correct 200 ms 17912 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 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 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 87 ms 10824 KB Output is correct
12 Correct 79 ms 10828 KB Output is correct
13 Correct 70 ms 9548 KB Output is correct
14 Correct 146 ms 17916 KB Output is correct
15 Correct 187 ms 17912 KB Output is correct
16 Correct 169 ms 17896 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 436 KB Output is correct
22 Correct 96 ms 10848 KB Output is correct
23 Correct 98 ms 11876 KB Output is correct
24 Correct 101 ms 11740 KB Output is correct
25 Correct 150 ms 17840 KB Output is correct
26 Correct 200 ms 17912 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 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 109 ms 10368 KB Output is correct
35 Correct 118 ms 12268 KB Output is correct
36 Correct 131 ms 13492 KB Output is correct
37 Correct 188 ms 17664 KB Output is correct
38 Correct 195 ms 17448 KB Output is correct
39 Correct 129 ms 10816 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 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 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 87 ms 10824 KB Output is correct
12 Correct 79 ms 10828 KB Output is correct
13 Correct 70 ms 9548 KB Output is correct
14 Correct 146 ms 17916 KB Output is correct
15 Correct 187 ms 17912 KB Output is correct
16 Correct 169 ms 17896 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 436 KB Output is correct
22 Correct 96 ms 10848 KB Output is correct
23 Correct 98 ms 11876 KB Output is correct
24 Correct 101 ms 11740 KB Output is correct
25 Correct 150 ms 17840 KB Output is correct
26 Correct 200 ms 17912 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 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 109 ms 10368 KB Output is correct
35 Correct 118 ms 12268 KB Output is correct
36 Correct 131 ms 13492 KB Output is correct
37 Correct 188 ms 17664 KB Output is correct
38 Correct 195 ms 17448 KB Output is correct
39 Correct 129 ms 10816 KB Output is correct
40 Correct 3 ms 596 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 724 KB Output is correct
44 Correct 118 ms 10804 KB Output is correct
45 Correct 195 ms 17280 KB Output is correct
46 Correct 181 ms 15468 KB Output is correct
47 Correct 220 ms 17828 KB Output is correct
48 Correct 222 ms 17912 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 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 224 KB Output is correct
10 Correct 1 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 544 KB Output is correct
27 Correct 4 ms 612 KB Output is correct
28 Correct 7 ms 608 KB Output is correct
29 Correct 6 ms 724 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 724 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 784 KB Output is correct
39 Correct 2 ms 452 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 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 1 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 10824 KB Output is correct
51 Correct 79 ms 10828 KB Output is correct
52 Correct 70 ms 9548 KB Output is correct
53 Correct 146 ms 17916 KB Output is correct
54 Correct 187 ms 17912 KB Output is correct
55 Correct 169 ms 17896 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 2 ms 436 KB Output is correct
61 Correct 96 ms 10848 KB Output is correct
62 Correct 98 ms 11876 KB Output is correct
63 Correct 101 ms 11740 KB Output is correct
64 Correct 150 ms 17840 KB Output is correct
65 Correct 200 ms 17912 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 340 KB Output is correct
68 Correct 0 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 109 ms 10368 KB Output is correct
74 Correct 118 ms 12268 KB Output is correct
75 Correct 131 ms 13492 KB Output is correct
76 Correct 188 ms 17664 KB Output is correct
77 Correct 195 ms 17448 KB Output is correct
78 Correct 129 ms 10816 KB Output is correct
79 Correct 3 ms 596 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 724 KB Output is correct
83 Correct 118 ms 10804 KB Output is correct
84 Correct 195 ms 17280 KB Output is correct
85 Correct 181 ms 15468 KB Output is correct
86 Correct 220 ms 17828 KB Output is correct
87 Correct 222 ms 17912 KB Output is correct
88 Correct 152 ms 10748 KB Output is correct
89 Correct 211 ms 15072 KB Output is correct
90 Correct 155 ms 11388 KB Output is correct
91 Correct 287 ms 17828 KB Output is correct
92 Correct 148 ms 12944 KB Output is correct
93 Correct 210 ms 16416 KB Output is correct
94 Correct 251 ms 17908 KB Output is correct
95 Correct 244 ms 17848 KB Output is correct
96 Correct 278 ms 17856 KB Output is correct
97 Correct 237 ms 17988 KB Output is correct
98 Correct 98 ms 10848 KB Output is correct
99 Correct 253 ms 17808 KB Output is correct