답안 #587574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587574 2022-07-02T05:53:56 Z Tekor Team Contest (JOI22_team) C++17
73 / 100
2000 ms 392536 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 = 4e3 + 100;
const ll LLINF = (ll)1e18;
ll a[N],b[N],c[N];
ll mn[M][M],mn1[M][M],mxc[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 <= 4000) {
		for(int i = 1;i <= mx;i++) {
			for(int j = 1;j <= mx;j++) {
				mn[i][j] = mx + 1;
				mn1[i][j] = mx + 1;
			}
		}
		for(int i = 1;i <= n;i++) {
			mn[a[i]][b[i] + 1] = min(mn[a[i]][b[i] + 1],c[i]);
			mn1[b[i]][a[i] + 1] = min(mn1[b[i]][a[i] + 1],c[i]);
			mxc[a[i] + 1][b[i] + 1] = max(mxc[a[i] + 1][b[i] + 1],c[i]);
		}
		for(int i = 1;i <= mx;i++) {
			for(int j = 1;j <= mx;j++) {
				if(j > 1) {
					mn[i][j] = min(mn[i][j],mn[i][j - 1]);
					mn1[i][j] = min(mn1[i][j],mn1[i][j - 1]);
					mxc[i][j] = max(mxc[i][j],mxc[i][j - 1]);
				}
				if(i > 1)mxc[i][j] = max(mxc[i][j],mxc[i - 1][j]);
			}
		}
		//cout << mn[5][5] << " " << mn1[5][5] << " " << mn2[5][5] << endl;
		for(int i = 1;i <= mx;i++) {
			for(int j = 1;j <= mx;j++) {
				int val = max(mn[i][j],mn1[j][i]);
				int pp = mxc[i][j];
				if(pp > val)ans = max(ans,(ll)(i + j + pp));
			}
		}
		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:85:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |   for(int j = 0;j < q.size();j++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 4 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 4 ms 6228 KB Output is correct
19 Correct 1 ms 2260 KB Output is correct
20 Correct 1 ms 596 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 1 ms 1920 KB Output is correct
25 Correct 1 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 4 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 4 ms 6228 KB Output is correct
19 Correct 1 ms 2260 KB Output is correct
20 Correct 1 ms 596 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 1 ms 1920 KB Output is correct
25 Correct 1 ms 1876 KB Output is correct
26 Correct 1012 ms 648 KB Output is correct
27 Correct 938 ms 696 KB Output is correct
28 Correct 932 ms 540 KB Output is correct
29 Correct 759 ms 544 KB Output is correct
30 Correct 189 ms 177456 KB Output is correct
31 Correct 63 ms 71308 KB Output is correct
32 Correct 4 ms 6484 KB Output is correct
33 Correct 70 ms 468 KB Output is correct
34 Correct 770 ms 876 KB Output is correct
35 Correct 4 ms 6344 KB Output is correct
36 Correct 4 ms 6356 KB Output is correct
37 Correct 49 ms 58700 KB Output is correct
38 Correct 50 ms 58572 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 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 23 ms 5440 KB Output is correct
12 Correct 15 ms 3728 KB Output is correct
13 Correct 24 ms 4464 KB Output is correct
14 Correct 30 ms 5332 KB Output is correct
15 Correct 30 ms 5256 KB Output is correct
16 Correct 31 ms 5228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 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 23 ms 5440 KB Output is correct
12 Correct 15 ms 3728 KB Output is correct
13 Correct 24 ms 4464 KB Output is correct
14 Correct 30 ms 5332 KB Output is correct
15 Correct 30 ms 5256 KB Output is correct
16 Correct 31 ms 5228 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 26 ms 5508 KB Output is correct
23 Correct 25 ms 5292 KB Output is correct
24 Correct 19 ms 4128 KB Output is correct
25 Correct 28 ms 5416 KB Output is correct
26 Correct 28 ms 5364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 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 23 ms 5440 KB Output is correct
12 Correct 15 ms 3728 KB Output is correct
13 Correct 24 ms 4464 KB Output is correct
14 Correct 30 ms 5332 KB Output is correct
15 Correct 30 ms 5256 KB Output is correct
16 Correct 31 ms 5228 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 26 ms 5508 KB Output is correct
23 Correct 25 ms 5292 KB Output is correct
24 Correct 19 ms 4128 KB Output is correct
25 Correct 28 ms 5416 KB Output is correct
26 Correct 28 ms 5364 KB Output is correct
27 Correct 3 ms 6228 KB Output is correct
28 Correct 1 ms 2260 KB Output is correct
29 Correct 1 ms 1876 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 4 ms 6484 KB Output is correct
32 Correct 4 ms 6356 KB Output is correct
33 Correct 4 ms 6356 KB Output is correct
34 Correct 32 ms 11004 KB Output is correct
35 Correct 39 ms 10664 KB Output is correct
36 Correct 35 ms 10816 KB Output is correct
37 Correct 32 ms 11128 KB Output is correct
38 Correct 29 ms 10688 KB Output is correct
39 Correct 20 ms 9244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 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 23 ms 5440 KB Output is correct
12 Correct 15 ms 3728 KB Output is correct
13 Correct 24 ms 4464 KB Output is correct
14 Correct 30 ms 5332 KB Output is correct
15 Correct 30 ms 5256 KB Output is correct
16 Correct 31 ms 5228 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 26 ms 5508 KB Output is correct
23 Correct 25 ms 5292 KB Output is correct
24 Correct 19 ms 4128 KB Output is correct
25 Correct 28 ms 5416 KB Output is correct
26 Correct 28 ms 5364 KB Output is correct
27 Correct 3 ms 6228 KB Output is correct
28 Correct 1 ms 2260 KB Output is correct
29 Correct 1 ms 1876 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 4 ms 6484 KB Output is correct
32 Correct 4 ms 6356 KB Output is correct
33 Correct 4 ms 6356 KB Output is correct
34 Correct 32 ms 11004 KB Output is correct
35 Correct 39 ms 10664 KB Output is correct
36 Correct 35 ms 10816 KB Output is correct
37 Correct 32 ms 11128 KB Output is correct
38 Correct 29 ms 10688 KB Output is correct
39 Correct 20 ms 9244 KB Output is correct
40 Correct 171 ms 177436 KB Output is correct
41 Correct 73 ms 71288 KB Output is correct
42 Correct 50 ms 58644 KB Output is correct
43 Correct 53 ms 58604 KB Output is correct
44 Correct 534 ms 390404 KB Output is correct
45 Correct 418 ms 356688 KB Output is correct
46 Correct 485 ms 391552 KB Output is correct
47 Correct 526 ms 392536 KB Output is correct
48 Correct 463 ms 354944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 4 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 4 ms 6228 KB Output is correct
19 Correct 1 ms 2260 KB Output is correct
20 Correct 1 ms 596 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 1 ms 1920 KB Output is correct
25 Correct 1 ms 1876 KB Output is correct
26 Correct 1012 ms 648 KB Output is correct
27 Correct 938 ms 696 KB Output is correct
28 Correct 932 ms 540 KB Output is correct
29 Correct 759 ms 544 KB Output is correct
30 Correct 189 ms 177456 KB Output is correct
31 Correct 63 ms 71308 KB Output is correct
32 Correct 4 ms 6484 KB Output is correct
33 Correct 70 ms 468 KB Output is correct
34 Correct 770 ms 876 KB Output is correct
35 Correct 4 ms 6344 KB Output is correct
36 Correct 4 ms 6356 KB Output is correct
37 Correct 49 ms 58700 KB Output is correct
38 Correct 50 ms 58572 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 0 ms 340 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 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 23 ms 5440 KB Output is correct
51 Correct 15 ms 3728 KB Output is correct
52 Correct 24 ms 4464 KB Output is correct
53 Correct 30 ms 5332 KB Output is correct
54 Correct 30 ms 5256 KB Output is correct
55 Correct 31 ms 5228 KB Output is correct
56 Correct 0 ms 468 KB Output is correct
57 Correct 0 ms 468 KB Output is correct
58 Correct 1 ms 468 KB Output is correct
59 Correct 1 ms 596 KB Output is correct
60 Correct 1 ms 596 KB Output is correct
61 Correct 26 ms 5508 KB Output is correct
62 Correct 25 ms 5292 KB Output is correct
63 Correct 19 ms 4128 KB Output is correct
64 Correct 28 ms 5416 KB Output is correct
65 Correct 28 ms 5364 KB Output is correct
66 Correct 3 ms 6228 KB Output is correct
67 Correct 1 ms 2260 KB Output is correct
68 Correct 1 ms 1876 KB Output is correct
69 Correct 1 ms 1876 KB Output is correct
70 Correct 4 ms 6484 KB Output is correct
71 Correct 4 ms 6356 KB Output is correct
72 Correct 4 ms 6356 KB Output is correct
73 Correct 32 ms 11004 KB Output is correct
74 Correct 39 ms 10664 KB Output is correct
75 Correct 35 ms 10816 KB Output is correct
76 Correct 32 ms 11128 KB Output is correct
77 Correct 29 ms 10688 KB Output is correct
78 Correct 20 ms 9244 KB Output is correct
79 Correct 171 ms 177436 KB Output is correct
80 Correct 73 ms 71288 KB Output is correct
81 Correct 50 ms 58644 KB Output is correct
82 Correct 53 ms 58604 KB Output is correct
83 Correct 534 ms 390404 KB Output is correct
84 Correct 418 ms 356688 KB Output is correct
85 Correct 485 ms 391552 KB Output is correct
86 Correct 526 ms 392536 KB Output is correct
87 Correct 463 ms 354944 KB Output is correct
88 Execution timed out 2067 ms 9044 KB Time limit exceeded
89 Halted 0 ms 0 KB -