Submission #547760

# Submission time Handle Problem Language Result Execution time Memory
547760 2022-04-11T16:00:33 Z Pherokung Team Contest (JOI22_team) C++14
100 / 100
102 ms 5652 KB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> pa;
int n,X[3][150005];
pa v[3][150005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=2;j++){
			scanf("%d",&X[j][i]);
			v[j][i] = {X[j][i],i};
		}
	
	for(int i=0;i<=2;i++) sort(v[i]+1, v[i]+n+1, greater<pa>());
	
	int a = 1, b = 1, c = 1;
	while(a <= n && b <= n && c <= n){
		int pa = v[0][a].S, pb = v[1][b].S, pc = v[2][c].S;
		
		if(X[1][pa] >= X[1][pb] || X[2][pa] >= X[2][pc]) {
			a++;
			continue;
		}
		if(X[0][pb] >= X[0][pa] || X[2][pb] >= X[2][pc]){
			b++;
			continue;
		} 
		if(X[0][pc] >= X[0][pa] || X[1][pc] >= X[1][pb]){
			c++;
			continue;
		} 
		break;
	}
	
	if(a <= n && b <= n && c <=n) printf("%d",v[0][a].F + v[1][b].F + v[2][c].F);
	else printf("-1");
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
team.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |    scanf("%d",&X[j][i]);
      |    ~~~~~^~~~~~~~~~~~~~~
# 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 0 ms 212 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 212 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 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 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 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 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 0 ms 212 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 212 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 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 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 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 1 ms 340 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 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 83 ms 5456 KB Output is correct
12 Correct 45 ms 3820 KB Output is correct
13 Correct 45 ms 4652 KB Output is correct
14 Correct 70 ms 5508 KB Output is correct
15 Correct 61 ms 5476 KB Output is correct
16 Correct 40 ms 5460 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 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 83 ms 5456 KB Output is correct
12 Correct 45 ms 3820 KB Output is correct
13 Correct 45 ms 4652 KB Output is correct
14 Correct 70 ms 5508 KB Output is correct
15 Correct 61 ms 5476 KB Output is correct
16 Correct 40 ms 5460 KB Output is correct
17 Correct 1 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 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 78 ms 5568 KB Output is correct
23 Correct 71 ms 5456 KB Output is correct
24 Correct 55 ms 4052 KB Output is correct
25 Correct 76 ms 5452 KB Output is correct
26 Correct 64 ms 5564 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 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 83 ms 5456 KB Output is correct
12 Correct 45 ms 3820 KB Output is correct
13 Correct 45 ms 4652 KB Output is correct
14 Correct 70 ms 5508 KB Output is correct
15 Correct 61 ms 5476 KB Output is correct
16 Correct 40 ms 5460 KB Output is correct
17 Correct 1 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 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 78 ms 5568 KB Output is correct
23 Correct 71 ms 5456 KB Output is correct
24 Correct 55 ms 4052 KB Output is correct
25 Correct 76 ms 5452 KB Output is correct
26 Correct 64 ms 5564 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 85 ms 5332 KB Output is correct
35 Correct 73 ms 5084 KB Output is correct
36 Correct 79 ms 5504 KB Output is correct
37 Correct 81 ms 5492 KB Output is correct
38 Correct 58 ms 5372 KB Output is correct
39 Correct 31 ms 3412 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 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 83 ms 5456 KB Output is correct
12 Correct 45 ms 3820 KB Output is correct
13 Correct 45 ms 4652 KB Output is correct
14 Correct 70 ms 5508 KB Output is correct
15 Correct 61 ms 5476 KB Output is correct
16 Correct 40 ms 5460 KB Output is correct
17 Correct 1 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 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 78 ms 5568 KB Output is correct
23 Correct 71 ms 5456 KB Output is correct
24 Correct 55 ms 4052 KB Output is correct
25 Correct 76 ms 5452 KB Output is correct
26 Correct 64 ms 5564 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 85 ms 5332 KB Output is correct
35 Correct 73 ms 5084 KB Output is correct
36 Correct 79 ms 5504 KB Output is correct
37 Correct 81 ms 5492 KB Output is correct
38 Correct 58 ms 5372 KB Output is correct
39 Correct 31 ms 3412 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 84 ms 5584 KB Output is correct
45 Correct 84 ms 5568 KB Output is correct
46 Correct 81 ms 5508 KB Output is correct
47 Correct 81 ms 5468 KB Output is correct
48 Correct 66 ms 5452 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 0 ms 212 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 212 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 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 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 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 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 1 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 83 ms 5456 KB Output is correct
51 Correct 45 ms 3820 KB Output is correct
52 Correct 45 ms 4652 KB Output is correct
53 Correct 70 ms 5508 KB Output is correct
54 Correct 61 ms 5476 KB Output is correct
55 Correct 40 ms 5460 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 0 ms 340 KB Output is correct
58 Correct 0 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 78 ms 5568 KB Output is correct
62 Correct 71 ms 5456 KB Output is correct
63 Correct 55 ms 4052 KB Output is correct
64 Correct 76 ms 5452 KB Output is correct
65 Correct 64 ms 5564 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 85 ms 5332 KB Output is correct
74 Correct 73 ms 5084 KB Output is correct
75 Correct 79 ms 5504 KB Output is correct
76 Correct 81 ms 5492 KB Output is correct
77 Correct 58 ms 5372 KB Output is correct
78 Correct 31 ms 3412 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 2 ms 468 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 2 ms 468 KB Output is correct
83 Correct 84 ms 5584 KB Output is correct
84 Correct 84 ms 5568 KB Output is correct
85 Correct 81 ms 5508 KB Output is correct
86 Correct 81 ms 5468 KB Output is correct
87 Correct 66 ms 5452 KB Output is correct
88 Correct 83 ms 5564 KB Output is correct
89 Correct 95 ms 5560 KB Output is correct
90 Correct 87 ms 5652 KB Output is correct
91 Correct 92 ms 5500 KB Output is correct
92 Correct 82 ms 5564 KB Output is correct
93 Correct 87 ms 5484 KB Output is correct
94 Correct 102 ms 5512 KB Output is correct
95 Correct 98 ms 5448 KB Output is correct
96 Correct 80 ms 5564 KB Output is correct
97 Correct 50 ms 5456 KB Output is correct
98 Correct 44 ms 5472 KB Output is correct
99 Correct 90 ms 5488 KB Output is correct