Submission #703839

# Submission time Handle Problem Language Result Execution time Memory
703839 2023-02-28T15:42:17 Z LittleCube Team Contest (JOI22_team) C++14
100 / 100
243 ms 7860 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

int N, A[150005], B[150005], C[150005];
vector<int> a, b, c;

signed main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i] >> B[i] >> C[i];
		a.emplace_back(i);
		b.emplace_back(i);
		c.emplace_back(i);
	}
	sort(a.begin(), a.end(), [&](int i, int j)
		 { return A[i] < A[j]; });
	sort(b.begin(), b.end(), [&](int i, int j)
		 { return B[i] < B[j]; });
	sort(c.begin(), c.end(), [&](int i, int j)
		 { return C[i] < C[j]; });

	while (!a.empty() && !b.empty() && !c.empty())
	{
		int i = a.back(), j = b.back(), k = c.back();
		if (B[i] >= B[j] || C[i] >= C[k])
		{
			a.pop_back();
			continue;
		}
		if (A[j] >= A[i] || C[j] >= C[k])
		{
			b.pop_back();
			continue;
		}
		if (A[k] >= A[i] || B[k] >= B[j])
		{
			c.pop_back();
			continue;
		}
		cout << A[i] + B[j] + C[k] << '\n';
		return 0;
	}
	cout << -1 << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 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 1 ms 312 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 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 312 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 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 316 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 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 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 1 ms 312 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 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 312 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 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 316 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 308 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 6 ms 452 KB Output is correct
28 Correct 5 ms 444 KB Output is correct
29 Correct 6 ms 468 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 4 ms 448 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 5 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 3 ms 468 KB Output is correct
38 Correct 4 ms 448 KB Output is correct
39 Correct 2 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 312 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 0 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 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 4824 KB Output is correct
12 Correct 51 ms 3400 KB Output is correct
13 Correct 54 ms 4004 KB Output is correct
14 Correct 69 ms 4832 KB Output is correct
15 Correct 67 ms 4924 KB Output is correct
16 Correct 64 ms 4840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 312 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 0 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 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 4824 KB Output is correct
12 Correct 51 ms 3400 KB Output is correct
13 Correct 54 ms 4004 KB Output is correct
14 Correct 69 ms 4832 KB Output is correct
15 Correct 67 ms 4924 KB Output is correct
16 Correct 64 ms 4840 KB Output is correct
17 Correct 1 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 340 KB Output is correct
22 Correct 94 ms 5052 KB Output is correct
23 Correct 75 ms 4924 KB Output is correct
24 Correct 67 ms 3704 KB Output is correct
25 Correct 89 ms 5180 KB Output is correct
26 Correct 73 ms 5016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 312 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 0 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 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 4824 KB Output is correct
12 Correct 51 ms 3400 KB Output is correct
13 Correct 54 ms 4004 KB Output is correct
14 Correct 69 ms 4832 KB Output is correct
15 Correct 67 ms 4924 KB Output is correct
16 Correct 64 ms 4840 KB Output is correct
17 Correct 1 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 340 KB Output is correct
22 Correct 94 ms 5052 KB Output is correct
23 Correct 75 ms 4924 KB Output is correct
24 Correct 67 ms 3704 KB Output is correct
25 Correct 89 ms 5180 KB Output is correct
26 Correct 73 ms 5016 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 308 KB Output is correct
31 Correct 4 ms 472 KB Output is correct
32 Correct 1 ms 312 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 99 ms 5552 KB Output is correct
35 Correct 99 ms 5456 KB Output is correct
36 Correct 105 ms 5564 KB Output is correct
37 Correct 109 ms 5692 KB Output is correct
38 Correct 93 ms 5544 KB Output is correct
39 Correct 56 ms 3496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 312 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 0 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 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 4824 KB Output is correct
12 Correct 51 ms 3400 KB Output is correct
13 Correct 54 ms 4004 KB Output is correct
14 Correct 69 ms 4832 KB Output is correct
15 Correct 67 ms 4924 KB Output is correct
16 Correct 64 ms 4840 KB Output is correct
17 Correct 1 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 340 KB Output is correct
22 Correct 94 ms 5052 KB Output is correct
23 Correct 75 ms 4924 KB Output is correct
24 Correct 67 ms 3704 KB Output is correct
25 Correct 89 ms 5180 KB Output is correct
26 Correct 73 ms 5016 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 308 KB Output is correct
31 Correct 4 ms 472 KB Output is correct
32 Correct 1 ms 312 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 99 ms 5552 KB Output is correct
35 Correct 99 ms 5456 KB Output is correct
36 Correct 105 ms 5564 KB Output is correct
37 Correct 109 ms 5692 KB Output is correct
38 Correct 93 ms 5544 KB Output is correct
39 Correct 56 ms 3496 KB Output is correct
40 Correct 3 ms 448 KB Output is correct
41 Correct 4 ms 448 KB Output is correct
42 Correct 3 ms 468 KB Output is correct
43 Correct 4 ms 468 KB Output is correct
44 Correct 135 ms 6160 KB Output is correct
45 Correct 134 ms 6076 KB Output is correct
46 Correct 131 ms 6040 KB Output is correct
47 Correct 131 ms 6092 KB Output is correct
48 Correct 108 ms 5948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 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 1 ms 312 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 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 312 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 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 316 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 308 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 6 ms 452 KB Output is correct
28 Correct 5 ms 444 KB Output is correct
29 Correct 6 ms 468 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 4 ms 448 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 5 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 3 ms 468 KB Output is correct
38 Correct 4 ms 448 KB Output is correct
39 Correct 2 ms 320 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 312 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 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 1 ms 212 KB Output is correct
48 Correct 0 ms 308 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 68 ms 4824 KB Output is correct
51 Correct 51 ms 3400 KB Output is correct
52 Correct 54 ms 4004 KB Output is correct
53 Correct 69 ms 4832 KB Output is correct
54 Correct 67 ms 4924 KB Output is correct
55 Correct 64 ms 4840 KB Output is correct
56 Correct 1 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 340 KB Output is correct
61 Correct 94 ms 5052 KB Output is correct
62 Correct 75 ms 4924 KB Output is correct
63 Correct 67 ms 3704 KB Output is correct
64 Correct 89 ms 5180 KB Output is correct
65 Correct 73 ms 5016 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 308 KB Output is correct
70 Correct 4 ms 472 KB Output is correct
71 Correct 1 ms 312 KB Output is correct
72 Correct 1 ms 312 KB Output is correct
73 Correct 99 ms 5552 KB Output is correct
74 Correct 99 ms 5456 KB Output is correct
75 Correct 105 ms 5564 KB Output is correct
76 Correct 109 ms 5692 KB Output is correct
77 Correct 93 ms 5544 KB Output is correct
78 Correct 56 ms 3496 KB Output is correct
79 Correct 3 ms 448 KB Output is correct
80 Correct 4 ms 448 KB Output is correct
81 Correct 3 ms 468 KB Output is correct
82 Correct 4 ms 468 KB Output is correct
83 Correct 135 ms 6160 KB Output is correct
84 Correct 134 ms 6076 KB Output is correct
85 Correct 131 ms 6040 KB Output is correct
86 Correct 131 ms 6092 KB Output is correct
87 Correct 108 ms 5948 KB Output is correct
88 Correct 189 ms 7784 KB Output is correct
89 Correct 243 ms 7836 KB Output is correct
90 Correct 190 ms 7788 KB Output is correct
91 Correct 195 ms 7724 KB Output is correct
92 Correct 147 ms 6372 KB Output is correct
93 Correct 162 ms 6648 KB Output is correct
94 Correct 159 ms 6504 KB Output is correct
95 Correct 166 ms 7768 KB Output is correct
96 Correct 187 ms 7860 KB Output is correct
97 Correct 160 ms 7792 KB Output is correct
98 Correct 119 ms 6500 KB Output is correct
99 Correct 175 ms 6432 KB Output is correct