Submission #617432

# Submission time Handle Problem Language Result Execution time Memory
617432 2022-08-01T11:19:07 Z patrikpavic2 Team Contest (JOI22_team) C++17
100 / 100
530 ms 21280 KB
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef pair < int, int > pii;

const int N = 2e5 + 500;

int n, x[N], y[N], z[N], izb[N];
vector < int > v;
set < pii > Sx, Sy;

bool cmp(int A, int B){
	if(z[A] == z[B]){
		if(x[A] == x[B])
			return y[A] < y[B];
		return x[A] < x[B];
	}
	return z[A] > z[B];
}

void izbaci(int k){
	if(izb[k]) return;
	izb[k] = 1;
	Sx.erase({x[k], k});
	Sy.erase({y[k], k});
}

int probaj_tri(int xx, int yy, int zz){
	if(x[xx] <= x[yy] || x[xx] <= x[zz])
		return -1;
	if(y[yy] <= y[xx] || y[yy] <= y[zz])
		return -1;
	if(z[zz] <= z[xx] || z[zz] <= z[yy])
		return -1;
	return x[xx] + y[yy] + z[zz];
}

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d%d%d", x + i, y + i, z + i);
		v.PB(i); 
		Sx.insert({x[i], i});
		Sy.insert({y[i], i});
	}
	sort(v.begin(), v.end(), cmp);
	int ans = -1;
	for(int i = 0;i < n;){
		int j = i;
		while(j < n && z[v[j]] == z[v[i]]) j++;
		for(int k = i;k < j;k++)
			izbaci(v[k]);
		while((int)Sx.size() > 0){
			int mx = Sx.rbegin() -> Y, my = Sy.rbegin() -> Y;
			if(y[mx] == y[my])
				izbaci(mx);
			else if(x[mx] == x[my])
				izbaci(my);
			else
				break;
		}
		if((int)Sx.size() > 0){
			int mx = Sx.rbegin() -> Y, my = Sy.rbegin() -> Y;
			for(int k = i;k < j;k++)
				ans = max(ans, probaj_tri(mx, my , v[k]));
		}
		i = j;
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
team.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d%d%d", x + i, y + i, z + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 244 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 292 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 244 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 292 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 6 ms 852 KB Output is correct
27 Correct 5 ms 848 KB Output is correct
28 Correct 5 ms 852 KB Output is correct
29 Correct 5 ms 820 KB Output is correct
30 Correct 4 ms 568 KB Output is correct
31 Correct 7 ms 724 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 4 ms 724 KB Output is correct
34 Correct 5 ms 856 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 5 ms 720 KB Output is correct
38 Correct 4 ms 724 KB Output is correct
39 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 252 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 306 ms 18152 KB Output is correct
12 Correct 134 ms 12240 KB Output is correct
13 Correct 148 ms 14940 KB Output is correct
14 Correct 262 ms 18076 KB Output is correct
15 Correct 172 ms 18192 KB Output is correct
16 Correct 167 ms 18160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 252 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 306 ms 18152 KB Output is correct
12 Correct 134 ms 12240 KB Output is correct
13 Correct 148 ms 14940 KB Output is correct
14 Correct 262 ms 18076 KB Output is correct
15 Correct 172 ms 18192 KB Output is correct
16 Correct 167 ms 18160 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 3 ms 436 KB Output is correct
22 Correct 389 ms 18380 KB Output is correct
23 Correct 298 ms 17840 KB Output is correct
24 Correct 184 ms 13380 KB Output is correct
25 Correct 325 ms 18332 KB Output is correct
26 Correct 203 ms 18284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 252 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 306 ms 18152 KB Output is correct
12 Correct 134 ms 12240 KB Output is correct
13 Correct 148 ms 14940 KB Output is correct
14 Correct 262 ms 18076 KB Output is correct
15 Correct 172 ms 18192 KB Output is correct
16 Correct 167 ms 18160 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 3 ms 436 KB Output is correct
22 Correct 389 ms 18380 KB Output is correct
23 Correct 298 ms 17840 KB Output is correct
24 Correct 184 ms 13380 KB Output is correct
25 Correct 325 ms 18332 KB Output is correct
26 Correct 203 ms 18284 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 292 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 5 ms 724 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 405 ms 18004 KB Output is correct
35 Correct 323 ms 17104 KB Output is correct
36 Correct 377 ms 18764 KB Output is correct
37 Correct 288 ms 18772 KB Output is correct
38 Correct 250 ms 18424 KB Output is correct
39 Correct 87 ms 11432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 252 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 306 ms 18152 KB Output is correct
12 Correct 134 ms 12240 KB Output is correct
13 Correct 148 ms 14940 KB Output is correct
14 Correct 262 ms 18076 KB Output is correct
15 Correct 172 ms 18192 KB Output is correct
16 Correct 167 ms 18160 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 3 ms 436 KB Output is correct
22 Correct 389 ms 18380 KB Output is correct
23 Correct 298 ms 17840 KB Output is correct
24 Correct 184 ms 13380 KB Output is correct
25 Correct 325 ms 18332 KB Output is correct
26 Correct 203 ms 18284 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 292 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 5 ms 724 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 405 ms 18004 KB Output is correct
35 Correct 323 ms 17104 KB Output is correct
36 Correct 377 ms 18764 KB Output is correct
37 Correct 288 ms 18772 KB Output is correct
38 Correct 250 ms 18424 KB Output is correct
39 Correct 87 ms 11432 KB Output is correct
40 Correct 3 ms 596 KB Output is correct
41 Correct 5 ms 724 KB Output is correct
42 Correct 5 ms 724 KB Output is correct
43 Correct 5 ms 724 KB Output is correct
44 Correct 393 ms 19340 KB Output is correct
45 Correct 316 ms 19432 KB Output is correct
46 Correct 335 ms 19500 KB Output is correct
47 Correct 300 ms 19376 KB Output is correct
48 Correct 228 ms 19324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 244 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 292 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 6 ms 852 KB Output is correct
27 Correct 5 ms 848 KB Output is correct
28 Correct 5 ms 852 KB Output is correct
29 Correct 5 ms 820 KB Output is correct
30 Correct 4 ms 568 KB Output is correct
31 Correct 7 ms 724 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 4 ms 724 KB Output is correct
34 Correct 5 ms 856 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 5 ms 720 KB Output is correct
38 Correct 4 ms 724 KB Output is correct
39 Correct 3 ms 468 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 1 ms 252 KB Output is correct
43 Correct 1 ms 292 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 306 ms 18152 KB Output is correct
51 Correct 134 ms 12240 KB Output is correct
52 Correct 148 ms 14940 KB Output is correct
53 Correct 262 ms 18076 KB Output is correct
54 Correct 172 ms 18192 KB Output is correct
55 Correct 167 ms 18160 KB Output is correct
56 Correct 1 ms 296 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 300 KB Output is correct
60 Correct 3 ms 436 KB Output is correct
61 Correct 389 ms 18380 KB Output is correct
62 Correct 298 ms 17840 KB Output is correct
63 Correct 184 ms 13380 KB Output is correct
64 Correct 325 ms 18332 KB Output is correct
65 Correct 203 ms 18284 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 292 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 296 KB Output is correct
70 Correct 5 ms 724 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 405 ms 18004 KB Output is correct
74 Correct 323 ms 17104 KB Output is correct
75 Correct 377 ms 18764 KB Output is correct
76 Correct 288 ms 18772 KB Output is correct
77 Correct 250 ms 18424 KB Output is correct
78 Correct 87 ms 11432 KB Output is correct
79 Correct 3 ms 596 KB Output is correct
80 Correct 5 ms 724 KB Output is correct
81 Correct 5 ms 724 KB Output is correct
82 Correct 5 ms 724 KB Output is correct
83 Correct 393 ms 19340 KB Output is correct
84 Correct 316 ms 19432 KB Output is correct
85 Correct 335 ms 19500 KB Output is correct
86 Correct 300 ms 19376 KB Output is correct
87 Correct 228 ms 19324 KB Output is correct
88 Correct 530 ms 21172 KB Output is correct
89 Correct 378 ms 21248 KB Output is correct
90 Correct 520 ms 21156 KB Output is correct
91 Correct 365 ms 21100 KB Output is correct
92 Correct 415 ms 19740 KB Output is correct
93 Correct 465 ms 19992 KB Output is correct
94 Correct 456 ms 19908 KB Output is correct
95 Correct 265 ms 21088 KB Output is correct
96 Correct 316 ms 21192 KB Output is correct
97 Correct 174 ms 21280 KB Output is correct
98 Correct 190 ms 19820 KB Output is correct
99 Correct 207 ms 19752 KB Output is correct