Submission #545349

# Submission time Handle Problem Language Result Execution time Memory
545349 2022-04-04T10:24:05 Z Meloric Team Contest (JOI22_team) C++14
100 / 100
104 ms 7436 KB
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

using namespace std;

const int inf  = 1e18;


void solve(){
	int n; cin >> n;
	vector<int> x(n), y(n), z(n);
	for(int i = 0; i< n; i++)cin >> x[i] >> y[i] >> z[i];
	vector<int> sx(n), sy(n), sz(n);
	for(int i = 0; i< n; i++)sx[i] = sy[i] = sz[i] = i;
	sort(all(sx), [&](int i, int j){return x[i] < x[j];});
	sort(all(sy), [&](int i, int j){return y[i] < y[j];});
	sort(all(sz), [&](int i, int j){return z[i] < z[j];});
	
	int a=n-1, b=n-1, c=n-1;
	
	while(a >= 0 && b >= 0 && c >= 0){
		if(y[sx[a]] >= y[sy[b]] || z[sx[a]] >= z[sz[c]]){a--; continue;}
		if(x[sy[b]] >= x[sx[a]] || z[sy[b]] >= z[sz[c]]){b--; continue;}
		if(x[sz[c]] >= x[sx[a]] || y[sz[c]] >= y[sy[b]]){c--; continue;}
		break;
	}
	if(a < 0 || b < 0 || c < 0)cout << -1;
	else cout << x[sx[a]] + y[sy[b]] + z[sz[c]];
}

	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t = 1;
	//cin >> t;
	while(t--)solve();
}
# Verdict Execution time Memory 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 1 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 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 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory 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 1 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 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 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 388 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 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 1 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory 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 47 ms 7304 KB Output is correct
12 Correct 26 ms 5000 KB Output is correct
13 Correct 28 ms 6056 KB Output is correct
14 Correct 37 ms 7368 KB Output is correct
15 Correct 34 ms 7308 KB Output is correct
16 Correct 28 ms 7356 KB Output is correct
# Verdict Execution time Memory 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 47 ms 7304 KB Output is correct
12 Correct 26 ms 5000 KB Output is correct
13 Correct 28 ms 6056 KB Output is correct
14 Correct 37 ms 7368 KB Output is correct
15 Correct 34 ms 7308 KB Output is correct
16 Correct 28 ms 7356 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 43 ms 7304 KB Output is correct
23 Correct 40 ms 7188 KB Output is correct
24 Correct 37 ms 5320 KB Output is correct
25 Correct 46 ms 7252 KB Output is correct
26 Correct 37 ms 7304 KB Output is correct
# Verdict Execution time Memory 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 47 ms 7304 KB Output is correct
12 Correct 26 ms 5000 KB Output is correct
13 Correct 28 ms 6056 KB Output is correct
14 Correct 37 ms 7368 KB Output is correct
15 Correct 34 ms 7308 KB Output is correct
16 Correct 28 ms 7356 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 43 ms 7304 KB Output is correct
23 Correct 40 ms 7188 KB Output is correct
24 Correct 37 ms 5320 KB Output is correct
25 Correct 46 ms 7252 KB Output is correct
26 Correct 37 ms 7304 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 70 ms 7040 KB Output is correct
35 Correct 60 ms 6708 KB Output is correct
36 Correct 54 ms 7372 KB Output is correct
37 Correct 53 ms 7280 KB Output is correct
38 Correct 39 ms 7104 KB Output is correct
39 Correct 24 ms 4492 KB Output is correct
# Verdict Execution time Memory 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 47 ms 7304 KB Output is correct
12 Correct 26 ms 5000 KB Output is correct
13 Correct 28 ms 6056 KB Output is correct
14 Correct 37 ms 7368 KB Output is correct
15 Correct 34 ms 7308 KB Output is correct
16 Correct 28 ms 7356 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 43 ms 7304 KB Output is correct
23 Correct 40 ms 7188 KB Output is correct
24 Correct 37 ms 5320 KB Output is correct
25 Correct 46 ms 7252 KB Output is correct
26 Correct 37 ms 7304 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 70 ms 7040 KB Output is correct
35 Correct 60 ms 6708 KB Output is correct
36 Correct 54 ms 7372 KB Output is correct
37 Correct 53 ms 7280 KB Output is correct
38 Correct 39 ms 7104 KB Output is correct
39 Correct 24 ms 4492 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 66 ms 7420 KB Output is correct
45 Correct 90 ms 7288 KB Output is correct
46 Correct 73 ms 7292 KB Output is correct
47 Correct 70 ms 7356 KB Output is correct
48 Correct 46 ms 7372 KB Output is correct
# Verdict Execution time Memory 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 1 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 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 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 388 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 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 1 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 1 ms 340 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 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 47 ms 7304 KB Output is correct
51 Correct 26 ms 5000 KB Output is correct
52 Correct 28 ms 6056 KB Output is correct
53 Correct 37 ms 7368 KB Output is correct
54 Correct 34 ms 7308 KB Output is correct
55 Correct 28 ms 7356 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 43 ms 7304 KB Output is correct
62 Correct 40 ms 7188 KB Output is correct
63 Correct 37 ms 5320 KB Output is correct
64 Correct 46 ms 7252 KB Output is correct
65 Correct 37 ms 7304 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 2 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 70 ms 7040 KB Output is correct
74 Correct 60 ms 6708 KB Output is correct
75 Correct 54 ms 7372 KB Output is correct
76 Correct 53 ms 7280 KB Output is correct
77 Correct 39 ms 7104 KB Output is correct
78 Correct 24 ms 4492 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 2 ms 468 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 2 ms 468 KB Output is correct
83 Correct 66 ms 7420 KB Output is correct
84 Correct 90 ms 7288 KB Output is correct
85 Correct 73 ms 7292 KB Output is correct
86 Correct 70 ms 7356 KB Output is correct
87 Correct 46 ms 7372 KB Output is correct
88 Correct 79 ms 7308 KB Output is correct
89 Correct 104 ms 7360 KB Output is correct
90 Correct 93 ms 7424 KB Output is correct
91 Correct 97 ms 7360 KB Output is correct
92 Correct 82 ms 7432 KB Output is correct
93 Correct 81 ms 7308 KB Output is correct
94 Correct 79 ms 7308 KB Output is correct
95 Correct 56 ms 7300 KB Output is correct
96 Correct 91 ms 7360 KB Output is correct
97 Correct 51 ms 7436 KB Output is correct
98 Correct 43 ms 7288 KB Output is correct
99 Correct 96 ms 7356 KB Output is correct