Submission #965932

# Submission time Handle Problem Language Result Execution time Memory
965932 2024-04-19T08:08:31 Z PM1 Team Contest (JOI22_team) C++17
100 / 100
111 ms 8488 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=2e5;
int n,a[mxn][3];
vector<int>z,zz,zzz;
bool cmp1(int x,int y){
	return a[x][0]<a[y][0];
}
bool cmp2(int x,int y){
	return a[x][1]<a[y][1];
}
bool cmp3(int x,int y){
	return a[x][2]<a[y][2];
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		z.push_back(i);
	}
	zzz=zz=z;
	sort(z.begin(),z.end(),cmp1);
	sort(zz.begin(),zz.end(),cmp2);
	sort(zzz.begin(),zzz.end(),cmp3);
	int p1=n-1,p2=n-1,p3=n-1;
	while(p1>-1 && p2>-1 && p3>-1){
		if(a[z[p1]][0]<= a[zz[p2]][0]){
			p2--;
			continue;
		}
		if(a[z[p1]][0]<= a[zzz[p3]][0]){
			p3--;
			continue;
		}
		if(a[zz[p2]][1]<= a[z[p1]][1]){
			p1--;
			continue;
		}
		if(a[zz[p2]][1]<= a[zzz[p3]][1]){
			p3--;
			continue;
		}
		if(a[zzz[p3]][2]<= a[z[p1]][2]){
			p1--;
			continue;
		}
		if(a[zzz[p3]][2]<= a[zz[p2]][2]){
			p2--;
			continue;
		}
		//cout<<z[p1]<<" "<<zz[p2]<<" "<<zzz[p3]<<'\n';
		cout<<a[z[p1]][0]+a[zz[p2]][1]+a[zzz[p3]][2];
		return 0;
	}
	cout<<-1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 2 ms 856 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 2 ms 436 KB Output is correct
33 Correct 2 ms 476 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 3 ms 604 KB Output is correct
39 Correct 1 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 548 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 40 ms 5580 KB Output is correct
12 Correct 26 ms 4572 KB Output is correct
13 Correct 28 ms 4992 KB Output is correct
14 Correct 40 ms 5288 KB Output is correct
15 Correct 35 ms 5336 KB Output is correct
16 Correct 32 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 548 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 40 ms 5580 KB Output is correct
12 Correct 26 ms 4572 KB Output is correct
13 Correct 28 ms 4992 KB Output is correct
14 Correct 40 ms 5288 KB Output is correct
15 Correct 35 ms 5336 KB Output is correct
16 Correct 32 ms 5328 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 436 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 46 ms 5592 KB Output is correct
23 Correct 41 ms 5324 KB Output is correct
24 Correct 34 ms 4796 KB Output is correct
25 Correct 47 ms 5720 KB Output is correct
26 Correct 36 ms 5592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 548 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 40 ms 5580 KB Output is correct
12 Correct 26 ms 4572 KB Output is correct
13 Correct 28 ms 4992 KB Output is correct
14 Correct 40 ms 5288 KB Output is correct
15 Correct 35 ms 5336 KB Output is correct
16 Correct 32 ms 5328 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 436 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 46 ms 5592 KB Output is correct
23 Correct 41 ms 5324 KB Output is correct
24 Correct 34 ms 4796 KB Output is correct
25 Correct 47 ms 5720 KB Output is correct
26 Correct 36 ms 5592 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 600 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 55 ms 5848 KB Output is correct
35 Correct 52 ms 5584 KB Output is correct
36 Correct 60 ms 6100 KB Output is correct
37 Correct 59 ms 6092 KB Output is correct
38 Correct 41 ms 6088 KB Output is correct
39 Correct 24 ms 4860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 548 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 40 ms 5580 KB Output is correct
12 Correct 26 ms 4572 KB Output is correct
13 Correct 28 ms 4992 KB Output is correct
14 Correct 40 ms 5288 KB Output is correct
15 Correct 35 ms 5336 KB Output is correct
16 Correct 32 ms 5328 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 436 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 46 ms 5592 KB Output is correct
23 Correct 41 ms 5324 KB Output is correct
24 Correct 34 ms 4796 KB Output is correct
25 Correct 47 ms 5720 KB Output is correct
26 Correct 36 ms 5592 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 600 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 55 ms 5848 KB Output is correct
35 Correct 52 ms 5584 KB Output is correct
36 Correct 60 ms 6100 KB Output is correct
37 Correct 59 ms 6092 KB Output is correct
38 Correct 41 ms 6088 KB Output is correct
39 Correct 24 ms 4860 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 1 ms 600 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 69 ms 6452 KB Output is correct
45 Correct 70 ms 6608 KB Output is correct
46 Correct 70 ms 6640 KB Output is correct
47 Correct 70 ms 6720 KB Output is correct
48 Correct 47 ms 6616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 2 ms 856 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 2 ms 436 KB Output is correct
33 Correct 2 ms 476 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 3 ms 604 KB Output is correct
39 Correct 1 ms 476 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 548 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 460 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 40 ms 5580 KB Output is correct
51 Correct 26 ms 4572 KB Output is correct
52 Correct 28 ms 4992 KB Output is correct
53 Correct 40 ms 5288 KB Output is correct
54 Correct 35 ms 5336 KB Output is correct
55 Correct 32 ms 5328 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 1 ms 344 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 436 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 46 ms 5592 KB Output is correct
62 Correct 41 ms 5324 KB Output is correct
63 Correct 34 ms 4796 KB Output is correct
64 Correct 47 ms 5720 KB Output is correct
65 Correct 36 ms 5592 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 600 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 2 ms 604 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 55 ms 5848 KB Output is correct
74 Correct 52 ms 5584 KB Output is correct
75 Correct 60 ms 6100 KB Output is correct
76 Correct 59 ms 6092 KB Output is correct
77 Correct 41 ms 6088 KB Output is correct
78 Correct 24 ms 4860 KB Output is correct
79 Correct 2 ms 348 KB Output is correct
80 Correct 2 ms 600 KB Output is correct
81 Correct 1 ms 600 KB Output is correct
82 Correct 2 ms 604 KB Output is correct
83 Correct 69 ms 6452 KB Output is correct
84 Correct 70 ms 6608 KB Output is correct
85 Correct 70 ms 6640 KB Output is correct
86 Correct 70 ms 6720 KB Output is correct
87 Correct 47 ms 6616 KB Output is correct
88 Correct 88 ms 8336 KB Output is correct
89 Correct 88 ms 8368 KB Output is correct
90 Correct 87 ms 8488 KB Output is correct
91 Correct 111 ms 8288 KB Output is correct
92 Correct 80 ms 7020 KB Output is correct
93 Correct 89 ms 7352 KB Output is correct
94 Correct 82 ms 7024 KB Output is correct
95 Correct 57 ms 8144 KB Output is correct
96 Correct 88 ms 8488 KB Output is correct
97 Correct 54 ms 8400 KB Output is correct
98 Correct 45 ms 7068 KB Output is correct
99 Correct 104 ms 7116 KB Output is correct