답안 #711964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711964 2023-03-17T19:41:46 Z aryan12 Team Contest (JOI22_team) C++17
100 / 100
138 ms 17336 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{
	int n;
	cin >> n;
	vector<array<int, 2> > a(n), b(n), c(n);
	vector<array<int, 3> > lmao;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i][0] >> b[i][0] >> c[i][0];
		a[i][1] = b[i][1] = c[i][1] = i;
		lmao.push_back({a[i][0], b[i][0], c[i][0]});
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int x = n - 1, y = n - 1, z = n - 1;
	while(x != -1 && y != -1 && z != -1)
	{
		int X = a[x][1], Y = b[y][1], Z = c[z][1];
		if(lmao[X][1] >= lmao[Y][1] || lmao[X][2] >= lmao[Z][2])
		{
			x--;
			continue;
		}
		if(lmao[Y][0] >= lmao[X][0] || lmao[Y][2] >= lmao[Z][2])
		{
			y--;
			continue;
		}
		if(lmao[Z][0] >= lmao[X][0] || lmao[Z][1] >= lmao[Y][1])
		{
			z--;
			continue;
		}
		cout << a[x][0] + b[y][0] + c[z][0] << "\n";
		return;
	}
	cout << "-1\n";
}

int32_t main() 
{
	auto begin = std::chrono::high_resolution_clock::now();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++) 
	{
		//cout << "Case #" << i << ": ";
		Solve();
	}
	auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
	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 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 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 336 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 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 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 336 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 3 ms 724 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 720 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 3 ms 720 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 724 KB Output is correct
34 Correct 3 ms 764 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 724 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 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 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 74 ms 13624 KB Output is correct
12 Correct 50 ms 8136 KB Output is correct
13 Correct 60 ms 9324 KB Output is correct
14 Correct 78 ms 14540 KB Output is correct
15 Correct 74 ms 14524 KB Output is correct
16 Correct 52 ms 14540 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 1 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 74 ms 13624 KB Output is correct
12 Correct 50 ms 8136 KB Output is correct
13 Correct 60 ms 9324 KB Output is correct
14 Correct 78 ms 14540 KB Output is correct
15 Correct 74 ms 14524 KB Output is correct
16 Correct 52 ms 14540 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 83 ms 14784 KB Output is correct
23 Correct 81 ms 14284 KB Output is correct
24 Correct 62 ms 9160 KB Output is correct
25 Correct 89 ms 14696 KB Output is correct
26 Correct 77 ms 14540 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 1 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 74 ms 13624 KB Output is correct
12 Correct 50 ms 8136 KB Output is correct
13 Correct 60 ms 9324 KB Output is correct
14 Correct 78 ms 14540 KB Output is correct
15 Correct 74 ms 14524 KB Output is correct
16 Correct 52 ms 14540 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 83 ms 14784 KB Output is correct
23 Correct 81 ms 14284 KB Output is correct
24 Correct 62 ms 9160 KB Output is correct
25 Correct 89 ms 14696 KB Output is correct
26 Correct 77 ms 14540 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 328 KB Output is correct
34 Correct 81 ms 14756 KB Output is correct
35 Correct 80 ms 14396 KB Output is correct
36 Correct 99 ms 15172 KB Output is correct
37 Correct 91 ms 15132 KB Output is correct
38 Correct 77 ms 14912 KB Output is correct
39 Correct 38 ms 8528 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 1 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 74 ms 13624 KB Output is correct
12 Correct 50 ms 8136 KB Output is correct
13 Correct 60 ms 9324 KB Output is correct
14 Correct 78 ms 14540 KB Output is correct
15 Correct 74 ms 14524 KB Output is correct
16 Correct 52 ms 14540 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 83 ms 14784 KB Output is correct
23 Correct 81 ms 14284 KB Output is correct
24 Correct 62 ms 9160 KB Output is correct
25 Correct 89 ms 14696 KB Output is correct
26 Correct 77 ms 14540 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 328 KB Output is correct
34 Correct 81 ms 14756 KB Output is correct
35 Correct 80 ms 14396 KB Output is correct
36 Correct 99 ms 15172 KB Output is correct
37 Correct 91 ms 15132 KB Output is correct
38 Correct 77 ms 14912 KB Output is correct
39 Correct 38 ms 8528 KB Output is correct
40 Correct 2 ms 596 KB Output is correct
41 Correct 3 ms 716 KB Output is correct
42 Correct 2 ms 724 KB Output is correct
43 Correct 3 ms 724 KB Output is correct
44 Correct 89 ms 15616 KB Output is correct
45 Correct 120 ms 15592 KB Output is correct
46 Correct 127 ms 15608 KB Output is correct
47 Correct 102 ms 15668 KB Output is correct
48 Correct 88 ms 15500 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 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 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 336 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 3 ms 724 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 720 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 3 ms 720 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 724 KB Output is correct
34 Correct 3 ms 764 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 724 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 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 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 74 ms 13624 KB Output is correct
51 Correct 50 ms 8136 KB Output is correct
52 Correct 60 ms 9324 KB Output is correct
53 Correct 78 ms 14540 KB Output is correct
54 Correct 74 ms 14524 KB Output is correct
55 Correct 52 ms 14540 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 468 KB Output is correct
61 Correct 83 ms 14784 KB Output is correct
62 Correct 81 ms 14284 KB Output is correct
63 Correct 62 ms 9160 KB Output is correct
64 Correct 89 ms 14696 KB Output is correct
65 Correct 77 ms 14540 KB Output is correct
66 Correct 1 ms 328 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 724 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 328 KB Output is correct
73 Correct 81 ms 14756 KB Output is correct
74 Correct 80 ms 14396 KB Output is correct
75 Correct 99 ms 15172 KB Output is correct
76 Correct 91 ms 15132 KB Output is correct
77 Correct 77 ms 14912 KB Output is correct
78 Correct 38 ms 8528 KB Output is correct
79 Correct 2 ms 596 KB Output is correct
80 Correct 3 ms 716 KB Output is correct
81 Correct 2 ms 724 KB Output is correct
82 Correct 3 ms 724 KB Output is correct
83 Correct 89 ms 15616 KB Output is correct
84 Correct 120 ms 15592 KB Output is correct
85 Correct 127 ms 15608 KB Output is correct
86 Correct 102 ms 15668 KB Output is correct
87 Correct 88 ms 15500 KB Output is correct
88 Correct 94 ms 17196 KB Output is correct
89 Correct 108 ms 17204 KB Output is correct
90 Correct 101 ms 17204 KB Output is correct
91 Correct 112 ms 17148 KB Output is correct
92 Correct 99 ms 15976 KB Output is correct
93 Correct 138 ms 16256 KB Output is correct
94 Correct 110 ms 15976 KB Output is correct
95 Correct 102 ms 17084 KB Output is correct
96 Correct 97 ms 17164 KB Output is correct
97 Correct 75 ms 17336 KB Output is correct
98 Correct 59 ms 15988 KB Output is correct
99 Correct 102 ms 16080 KB Output is correct