Submission #587716

# Submission time Handle Problem Language Result Execution time Memory
587716 2022-07-02T09:20:33 Z LastRonin Team Contest (JOI22_team) C++14
35 / 100
1509 ms 14812 KB
#pragma GCC optimize("O3")

#include <bits/stdc++.h> 
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define pill pair<ll, ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

const int N = 2e5 + 1;
const ll hsh[2] = {1555555699, 1222222763};
const ll P = 113;

ll n;
ll a[N], b[N], c[N];
vector<pill> g[3][310];
int main() {
	speed;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	ll sum = -1;
	if(n <= 300) {
		for(int j = 0; j < n; j++) {
			for(int i = 0; i < n; i++) {
				for(int k = 0; k < n; k++) { 
					if(a[j] > max(a[i], a[k]) && b[i] > max(b[j], b[k]) && c[k] > max(c[j], c[i])) {
						sum = max(sum, a[j] + b[i] + c[k]);
					}
				}
			}
		}
		cout << sum;
	} else {
		for(int i = 0; i < n; i++) {
			g[0][a[i]].pb(mp(b[i], c[i]));
			g[1][b[i]].pb(mp(a[i], c[i]));
			g[2][c[i]].pb(mp(a[i], b[i]));
		}
		for(int j = 0; j < 3; j++) {
			for(int x = 0; x <= 300; x++) {
				sort(g[j][x].begin(), g[j][x].end());
				for(int i = 1; i < g[j][x].size(); i++) {
					g[j][x][i].s = min(g[j][x][i].s, g[j][x][i - 1].s);
			   	}
				g[j][x].erase(unique(g[j][x].begin(), g[j][x].end()), g[j][x].end());							
			}			
		}
		for(int i = 1; i <= 300; i++) {
			for(int j = 1; j <= 300; j++) {
				for(int k = 1; k <= 300; k++) {
					ll l = 0, r = ((ll)g[0][i].size()) - 1, ans = -1, ans2 = -1, ans3 = -1;
					while(l <= r) {
						ll m = (l + r) >> 1ll;
						if(g[0][i][m].f < j) {
							ans = m;
							l = m + 1;
						} else r = m - 1;
					}
					if(ans == -1)continue;
					l = 0, r = ((ll)g[1][j].size()) - 1;
					while(l <= r) {
						ll m = (l + r) >> 1ll;
						if(g[1][j][m].f < i) {
							ans2 = m;
							l = m + 1;
						} else r = m - 1;
					}
					if(ans2 == -1)continue;
					l = 0, r = ((ll)g[2][k].size()) - 1;
					while(l <= r) {
						ll m = (l + r) >> 1ll;
						if(g[2][k][m].f < i) {
							ans3 = m;
							l = m + 1;
						} else r = m - 1;
					}
					if(ans3 == -1)continue;
					if(g[0][i][ans].s < k && g[1][j][ans2].s < k && g[2][k][ans3].s < j) {
						sum = max(sum, (ll)(i + j + k));
					}
				}
 			}
		}
		cout << sum;
	}
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i = 1; i < g[j][x].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 58 ms 340 KB Output is correct
15 Correct 24 ms 340 KB Output is correct
16 Correct 37 ms 364 KB Output is correct
17 Correct 46 ms 340 KB Output is correct
18 Correct 46 ms 340 KB Output is correct
19 Correct 70 ms 356 KB Output is correct
20 Correct 47 ms 360 KB Output is correct
21 Correct 32 ms 340 KB Output is correct
22 Correct 35 ms 340 KB Output is correct
23 Correct 28 ms 372 KB Output is correct
24 Correct 29 ms 356 KB Output is correct
25 Correct 30 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 58 ms 340 KB Output is correct
15 Correct 24 ms 340 KB Output is correct
16 Correct 37 ms 364 KB Output is correct
17 Correct 46 ms 340 KB Output is correct
18 Correct 46 ms 340 KB Output is correct
19 Correct 70 ms 356 KB Output is correct
20 Correct 47 ms 360 KB Output is correct
21 Correct 32 ms 340 KB Output is correct
22 Correct 35 ms 340 KB Output is correct
23 Correct 28 ms 372 KB Output is correct
24 Correct 29 ms 356 KB Output is correct
25 Correct 30 ms 360 KB Output is correct
26 Runtime error 2 ms 724 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 88 ms 11108 KB Output is correct
12 Correct 60 ms 8216 KB Output is correct
13 Correct 75 ms 9392 KB Output is correct
14 Correct 78 ms 13080 KB Output is correct
15 Correct 69 ms 11988 KB Output is correct
16 Correct 65 ms 12208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 88 ms 11108 KB Output is correct
12 Correct 60 ms 8216 KB Output is correct
13 Correct 75 ms 9392 KB Output is correct
14 Correct 78 ms 13080 KB Output is correct
15 Correct 69 ms 11988 KB Output is correct
16 Correct 65 ms 12208 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 47 ms 364 KB Output is correct
21 Correct 53 ms 564 KB Output is correct
22 Correct 101 ms 12148 KB Output is correct
23 Correct 89 ms 11444 KB Output is correct
24 Correct 75 ms 9460 KB Output is correct
25 Correct 100 ms 12624 KB Output is correct
26 Correct 73 ms 11516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 88 ms 11108 KB Output is correct
12 Correct 60 ms 8216 KB Output is correct
13 Correct 75 ms 9392 KB Output is correct
14 Correct 78 ms 13080 KB Output is correct
15 Correct 69 ms 11988 KB Output is correct
16 Correct 65 ms 12208 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 47 ms 364 KB Output is correct
21 Correct 53 ms 564 KB Output is correct
22 Correct 101 ms 12148 KB Output is correct
23 Correct 89 ms 11444 KB Output is correct
24 Correct 75 ms 9460 KB Output is correct
25 Correct 100 ms 12624 KB Output is correct
26 Correct 73 ms 11516 KB Output is correct
27 Correct 51 ms 356 KB Output is correct
28 Correct 65 ms 352 KB Output is correct
29 Correct 33 ms 352 KB Output is correct
30 Correct 31 ms 376 KB Output is correct
31 Correct 374 ms 724 KB Output is correct
32 Correct 104 ms 432 KB Output is correct
33 Correct 81 ms 340 KB Output is correct
34 Correct 1411 ms 12128 KB Output is correct
35 Correct 1509 ms 14192 KB Output is correct
36 Correct 1427 ms 14812 KB Output is correct
37 Correct 1156 ms 13668 KB Output is correct
38 Correct 126 ms 11852 KB Output is correct
39 Correct 65 ms 8940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 88 ms 11108 KB Output is correct
12 Correct 60 ms 8216 KB Output is correct
13 Correct 75 ms 9392 KB Output is correct
14 Correct 78 ms 13080 KB Output is correct
15 Correct 69 ms 11988 KB Output is correct
16 Correct 65 ms 12208 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 47 ms 364 KB Output is correct
21 Correct 53 ms 564 KB Output is correct
22 Correct 101 ms 12148 KB Output is correct
23 Correct 89 ms 11444 KB Output is correct
24 Correct 75 ms 9460 KB Output is correct
25 Correct 100 ms 12624 KB Output is correct
26 Correct 73 ms 11516 KB Output is correct
27 Correct 51 ms 356 KB Output is correct
28 Correct 65 ms 352 KB Output is correct
29 Correct 33 ms 352 KB Output is correct
30 Correct 31 ms 376 KB Output is correct
31 Correct 374 ms 724 KB Output is correct
32 Correct 104 ms 432 KB Output is correct
33 Correct 81 ms 340 KB Output is correct
34 Correct 1411 ms 12128 KB Output is correct
35 Correct 1509 ms 14192 KB Output is correct
36 Correct 1427 ms 14812 KB Output is correct
37 Correct 1156 ms 13668 KB Output is correct
38 Correct 126 ms 11852 KB Output is correct
39 Correct 65 ms 8940 KB Output is correct
40 Runtime error 2 ms 596 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 58 ms 340 KB Output is correct
15 Correct 24 ms 340 KB Output is correct
16 Correct 37 ms 364 KB Output is correct
17 Correct 46 ms 340 KB Output is correct
18 Correct 46 ms 340 KB Output is correct
19 Correct 70 ms 356 KB Output is correct
20 Correct 47 ms 360 KB Output is correct
21 Correct 32 ms 340 KB Output is correct
22 Correct 35 ms 340 KB Output is correct
23 Correct 28 ms 372 KB Output is correct
24 Correct 29 ms 356 KB Output is correct
25 Correct 30 ms 360 KB Output is correct
26 Runtime error 2 ms 724 KB Execution killed with signal 11
27 Halted 0 ms 0 KB -