Submission #587715

# Submission time Handle Problem Language Result Execution time Memory
587715 2022-07-02T09:19:40 Z LastRonin Team Contest (JOI22_team) C++14
27 / 100
1520 ms 15612 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];
		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());							
		}			
	}
	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 = 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:32:21: 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]
   32 |    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 1 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 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 Runtime error 1 ms 468 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 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 Runtime error 1 ms 468 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 ms 340 KB Output is correct
11 Correct 88 ms 11940 KB Output is correct
12 Correct 53 ms 8784 KB Output is correct
13 Correct 58 ms 9884 KB Output is correct
14 Correct 71 ms 13752 KB Output is correct
15 Correct 65 ms 12840 KB Output is correct
16 Correct 59 ms 12556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 ms 340 KB Output is correct
11 Correct 88 ms 11940 KB Output is correct
12 Correct 53 ms 8784 KB Output is correct
13 Correct 58 ms 9884 KB Output is correct
14 Correct 71 ms 13752 KB Output is correct
15 Correct 65 ms 12840 KB Output is correct
16 Correct 59 ms 12556 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 344 KB Output is correct
20 Correct 36 ms 340 KB Output is correct
21 Correct 34 ms 596 KB Output is correct
22 Correct 99 ms 13148 KB Output is correct
23 Correct 107 ms 11672 KB Output is correct
24 Correct 81 ms 9896 KB Output is correct
25 Correct 98 ms 12992 KB Output is correct
26 Correct 66 ms 11744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 ms 340 KB Output is correct
11 Correct 88 ms 11940 KB Output is correct
12 Correct 53 ms 8784 KB Output is correct
13 Correct 58 ms 9884 KB Output is correct
14 Correct 71 ms 13752 KB Output is correct
15 Correct 65 ms 12840 KB Output is correct
16 Correct 59 ms 12556 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 344 KB Output is correct
20 Correct 36 ms 340 KB Output is correct
21 Correct 34 ms 596 KB Output is correct
22 Correct 99 ms 13148 KB Output is correct
23 Correct 107 ms 11672 KB Output is correct
24 Correct 81 ms 9896 KB Output is correct
25 Correct 98 ms 12992 KB Output is correct
26 Correct 66 ms 11744 KB Output is correct
27 Correct 43 ms 340 KB Output is correct
28 Correct 53 ms 380 KB Output is correct
29 Correct 25 ms 388 KB Output is correct
30 Correct 24 ms 340 KB Output is correct
31 Correct 394 ms 776 KB Output is correct
32 Correct 92 ms 340 KB Output is correct
33 Correct 93 ms 364 KB Output is correct
34 Correct 1490 ms 13648 KB Output is correct
35 Correct 1520 ms 15612 KB Output is correct
36 Correct 1474 ms 14948 KB Output is correct
37 Correct 1107 ms 15200 KB Output is correct
38 Correct 105 ms 13340 KB Output is correct
39 Correct 52 ms 9804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 ms 340 KB Output is correct
11 Correct 88 ms 11940 KB Output is correct
12 Correct 53 ms 8784 KB Output is correct
13 Correct 58 ms 9884 KB Output is correct
14 Correct 71 ms 13752 KB Output is correct
15 Correct 65 ms 12840 KB Output is correct
16 Correct 59 ms 12556 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 344 KB Output is correct
20 Correct 36 ms 340 KB Output is correct
21 Correct 34 ms 596 KB Output is correct
22 Correct 99 ms 13148 KB Output is correct
23 Correct 107 ms 11672 KB Output is correct
24 Correct 81 ms 9896 KB Output is correct
25 Correct 98 ms 12992 KB Output is correct
26 Correct 66 ms 11744 KB Output is correct
27 Correct 43 ms 340 KB Output is correct
28 Correct 53 ms 380 KB Output is correct
29 Correct 25 ms 388 KB Output is correct
30 Correct 24 ms 340 KB Output is correct
31 Correct 394 ms 776 KB Output is correct
32 Correct 92 ms 340 KB Output is correct
33 Correct 93 ms 364 KB Output is correct
34 Correct 1490 ms 13648 KB Output is correct
35 Correct 1520 ms 15612 KB Output is correct
36 Correct 1474 ms 14948 KB Output is correct
37 Correct 1107 ms 15200 KB Output is correct
38 Correct 105 ms 13340 KB Output is correct
39 Correct 52 ms 9804 KB Output is correct
40 Runtime error 1 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 1 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 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 Runtime error 1 ms 468 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -