Submission #587537

# Submission time Handle Problem Language Result Execution time Memory
587537 2022-07-02T05:05:55 Z Tekor Team Contest (JOI22_team) C++17
55 / 100
2000 ms 6596 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
void boos() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 3e5 + 100;
const int M = 21;
const ll LLINF = (ll)1e18;
ll a[N],b[N],c[N];
bool u[M][M][M],u1[M][M][M],u2[M][M][M];
int n;
bool cmp(int x,int y) {
	return a[x] < a[y];
}
bool cmp1(int x,int y) {
	return b[x] < b[y];
}
ll check(ll x,ll y,ll t) {
	bool ch = 0,ch1 = 0,ch2 = 0;
	for(int i = 1;i <= n;i++) {
		if(a[i] == x && b[i] < y && c[i] < t)ch = 1;
		if(a[i] < x && b[i] == y && c[i] < t)ch1 = 1;
		if(a[i] < x && b[i] < y && c[i] == t)ch2 = 1;
	}
	if(ch && ch1 && ch2)return x + y + t;
	else return -1;
}
void solve() {
	cin >> n;
	vector <int> g,q;
	ll mx = 0;
	for(int i = 1;i <= n;i++) {
		cin >> a[i] >> b[i] >> c[i];
		mx = max(mx,a[i]);
		mx = max(mx,b[i]);
		mx = max(mx,c[i]);
		g.pb(i);
		q.pb(i);
	}
	ll ans = -1;
	if(mx <= 20) {
		for(int i = 1;i <= n;i++) {
			for(int j = b[i] + 1;j <= mx;j++) {
				for(int h = c[i] + 1;h <= mx;h++) {
					u[a[i]][j][h] = 1;
				}
			}
			for(int j = a[i] + 1;j <= mx;j++) {
				for(int h = c[i] + 1;h <= mx;h++) {
					u1[b[i]][j][h] = 1;
				}
			}
			for(int j = a[i] + 1;j <= mx;j++) {
				for(int h = b[i] + 1;h <= mx;h++) {
					u2[c[i]][j][h] = 1;
				}
			}
		}
		for(int i = 1;i <= mx;i++) {
			for(int j = 1;j <= mx;j++) {
				for(int h = 1;h <= mx;h++) {
					if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,(ll)(i + j + h));
				}
			}
		}
		cout << ans;
		return;
	}
	sort(all(g),cmp);
	sort(all(q),cmp1);
	for(auto v : g) {
		ll mxa = a[v];
		set <ll> tt;
		//cout << v << " -- " << a[v] << endl;
		for(int j = 0;j < q.size();j++) {
			int to = q[j];
			ll mxb = b[to];
			//cout << to << " :: " << b[to] << " == ";
			if(j > 0 && b[q[j - 1]] != b[to]) {
				int pos = j - 1;
				while(pos >= 0 && b[q[pos]] == b[q[j - 1]]) {
					int p = q[pos];
					if(a[p] < mxa)tt.insert(c[p]);
					pos--;
				}	
			}
			if(a[to] >= mxa || b[v] >= mxb) {
				//cout << "fail" << endl;
				continue;
			}
			if(!tt.empty()) {
				ll val = *(tt.rbegin());
				if(val > max(c[v],c[to]))ans = max(ans,mxa + mxb + val);
				//cout << val << " ";
			}
			//cout << ans << endl;
		}
		//cout << ans << endl;
	} 
	cout << ans;
}
int main() {
	boos();
	solve();
}

Compilation message

team.cpp: In function 'void solve()':
team.cpp:80:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |   for(int j = 0;j < q.size();j++) {
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 340 KB Output is correct
15 Correct 7 ms 368 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 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 4 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 340 KB Output is correct
15 Correct 7 ms 368 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 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 4 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1048 ms 716 KB Output is correct
27 Correct 967 ms 852 KB Output is correct
28 Correct 910 ms 860 KB Output is correct
29 Correct 780 ms 636 KB Output is correct
30 Correct 370 ms 596 KB Output is correct
31 Correct 721 ms 616 KB Output is correct
32 Correct 429 ms 524 KB Output is correct
33 Correct 72 ms 572 KB Output is correct
34 Correct 836 ms 740 KB Output is correct
35 Correct 24 ms 404 KB Output is correct
36 Correct 21 ms 396 KB Output is correct
37 Correct 555 ms 548 KB Output is correct
38 Correct 556 ms 572 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 39 ms 5408 KB Output is correct
12 Correct 22 ms 3732 KB Output is correct
13 Correct 27 ms 4552 KB Output is correct
14 Correct 34 ms 5272 KB Output is correct
15 Correct 28 ms 5372 KB Output is correct
16 Correct 23 ms 5340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 39 ms 5408 KB Output is correct
12 Correct 22 ms 3732 KB Output is correct
13 Correct 27 ms 4552 KB Output is correct
14 Correct 34 ms 5272 KB Output is correct
15 Correct 28 ms 5372 KB Output is correct
16 Correct 23 ms 5340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 49 ms 5384 KB Output is correct
23 Correct 57 ms 6168 KB Output is correct
24 Correct 37 ms 4880 KB Output is correct
25 Correct 59 ms 6332 KB Output is correct
26 Correct 50 ms 6188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 39 ms 5408 KB Output is correct
12 Correct 22 ms 3732 KB Output is correct
13 Correct 27 ms 4552 KB Output is correct
14 Correct 34 ms 5272 KB Output is correct
15 Correct 28 ms 5372 KB Output is correct
16 Correct 23 ms 5340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 49 ms 5384 KB Output is correct
23 Correct 57 ms 6168 KB Output is correct
24 Correct 37 ms 4880 KB Output is correct
25 Correct 59 ms 6332 KB Output is correct
26 Correct 50 ms 6188 KB Output is correct
27 Correct 4 ms 364 KB Output is correct
28 Correct 4 ms 340 KB Output is correct
29 Correct 2 ms 328 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 402 ms 524 KB Output is correct
32 Correct 21 ms 340 KB Output is correct
33 Correct 21 ms 336 KB Output is correct
34 Execution timed out 2085 ms 6596 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 39 ms 5408 KB Output is correct
12 Correct 22 ms 3732 KB Output is correct
13 Correct 27 ms 4552 KB Output is correct
14 Correct 34 ms 5272 KB Output is correct
15 Correct 28 ms 5372 KB Output is correct
16 Correct 23 ms 5340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 49 ms 5384 KB Output is correct
23 Correct 57 ms 6168 KB Output is correct
24 Correct 37 ms 4880 KB Output is correct
25 Correct 59 ms 6332 KB Output is correct
26 Correct 50 ms 6188 KB Output is correct
27 Correct 4 ms 364 KB Output is correct
28 Correct 4 ms 340 KB Output is correct
29 Correct 2 ms 328 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 402 ms 524 KB Output is correct
32 Correct 21 ms 340 KB Output is correct
33 Correct 21 ms 336 KB Output is correct
34 Execution timed out 2085 ms 6596 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 340 KB Output is correct
15 Correct 7 ms 368 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 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 4 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1048 ms 716 KB Output is correct
27 Correct 967 ms 852 KB Output is correct
28 Correct 910 ms 860 KB Output is correct
29 Correct 780 ms 636 KB Output is correct
30 Correct 370 ms 596 KB Output is correct
31 Correct 721 ms 616 KB Output is correct
32 Correct 429 ms 524 KB Output is correct
33 Correct 72 ms 572 KB Output is correct
34 Correct 836 ms 740 KB Output is correct
35 Correct 24 ms 404 KB Output is correct
36 Correct 21 ms 396 KB Output is correct
37 Correct 555 ms 548 KB Output is correct
38 Correct 556 ms 572 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 328 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 1 ms 324 KB Output is correct
45 Correct 1 ms 328 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 39 ms 5408 KB Output is correct
51 Correct 22 ms 3732 KB Output is correct
52 Correct 27 ms 4552 KB Output is correct
53 Correct 34 ms 5272 KB Output is correct
54 Correct 28 ms 5372 KB Output is correct
55 Correct 23 ms 5340 KB Output is correct
56 Correct 0 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 0 ms 328 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 49 ms 5384 KB Output is correct
62 Correct 57 ms 6168 KB Output is correct
63 Correct 37 ms 4880 KB Output is correct
64 Correct 59 ms 6332 KB Output is correct
65 Correct 50 ms 6188 KB Output is correct
66 Correct 4 ms 364 KB Output is correct
67 Correct 4 ms 340 KB Output is correct
68 Correct 2 ms 328 KB Output is correct
69 Correct 2 ms 340 KB Output is correct
70 Correct 402 ms 524 KB Output is correct
71 Correct 21 ms 340 KB Output is correct
72 Correct 21 ms 336 KB Output is correct
73 Execution timed out 2085 ms 6596 KB Time limit exceeded
74 Halted 0 ms 0 KB -