# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
620024 |
2022-08-02T18:58:53 Z |
CSQ31 |
Team Contest (JOI22_team) |
C++17 |
|
208 ms |
7860 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
typedef pair<int,int> pii;
typedef long long int ll;
const int MAXN = 5e5;
int a[MAXN],b[MAXN],c[MAXN];
bool del[MAXN];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
vector<int>pa(n),pb(n),pc(n);
for(int i=0;i<n;i++){
pa[i] = pb[i] = pc[i] = i;
}
sort(all(pa),[&](int i,int j){return a[j] > a[i];});
sort(all(pb),[&](int i,int j){return b[j] > b[i];});
sort(all(pc),[&](int i,int j){return c[j] > c[i];});
int ta,tb,tc;
ta = tb = tc = n-1;
while(ta>=0 && tb>=0 && tc>=0){
int cnta = 0,cntb = 0,cntc = 0;
if(b[pa[ta]] == b[pb[tb]])cnta++;
if(c[pa[ta]] == c[pc[tc]])cnta++;
if(a[pb[tb]] == a[pa[ta]])cntb++;
if(c[pb[tb]] == c[pc[tc]])cntb++;
if(a[pc[tc]] == a[pa[ta]])cntc++;
if(b[pc[tc]] == b[pb[tb]])cntc++;
//cout<<ta<<" "<<tb<<" "<<tc<<'\n';
if(cnta>=1){
del[pa[ta]] = 1;
ta--;
}
else if(cntb>=1){
del[pb[tb]] = 1;
tb--;
}
else if(cntc>=1){
del[pc[tc]] = 1;
tc--;
}
else{
cout<<a[pa[ta]] + b[pb[tb]] + c[pc[tc]]<<'\n';
return 0;
}
while(ta != -1 && del[pa[ta]])ta--;
while(tb != -1 && del[pb[tb]])tb--;
while(tc != -1 && del[pc[tc]])tc--;
}
cout<<-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
228 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
312 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 |
308 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 |
312 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
228 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
312 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 |
308 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 |
312 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 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 |
5 ms |
460 KB |
Output is correct |
27 |
Correct |
6 ms |
468 KB |
Output is correct |
28 |
Correct |
6 ms |
468 KB |
Output is correct |
29 |
Correct |
6 ms |
448 KB |
Output is correct |
30 |
Correct |
3 ms |
340 KB |
Output is correct |
31 |
Correct |
4 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
448 KB |
Output is correct |
33 |
Correct |
5 ms |
452 KB |
Output is correct |
34 |
Correct |
6 ms |
476 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
3 ms |
444 KB |
Output is correct |
38 |
Correct |
5 ms |
400 KB |
Output is correct |
39 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 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 |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
73 ms |
4704 KB |
Output is correct |
12 |
Correct |
49 ms |
3284 KB |
Output is correct |
13 |
Correct |
57 ms |
4044 KB |
Output is correct |
14 |
Correct |
72 ms |
4844 KB |
Output is correct |
15 |
Correct |
68 ms |
5016 KB |
Output is correct |
16 |
Correct |
64 ms |
4788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 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 |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
73 ms |
4704 KB |
Output is correct |
12 |
Correct |
49 ms |
3284 KB |
Output is correct |
13 |
Correct |
57 ms |
4044 KB |
Output is correct |
14 |
Correct |
72 ms |
4844 KB |
Output is correct |
15 |
Correct |
68 ms |
5016 KB |
Output is correct |
16 |
Correct |
64 ms |
4788 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
308 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
88 ms |
4912 KB |
Output is correct |
23 |
Correct |
75 ms |
4712 KB |
Output is correct |
24 |
Correct |
61 ms |
3668 KB |
Output is correct |
25 |
Correct |
88 ms |
5100 KB |
Output is correct |
26 |
Correct |
75 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 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 |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
73 ms |
4704 KB |
Output is correct |
12 |
Correct |
49 ms |
3284 KB |
Output is correct |
13 |
Correct |
57 ms |
4044 KB |
Output is correct |
14 |
Correct |
72 ms |
4844 KB |
Output is correct |
15 |
Correct |
68 ms |
5016 KB |
Output is correct |
16 |
Correct |
64 ms |
4788 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
308 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
88 ms |
4912 KB |
Output is correct |
23 |
Correct |
75 ms |
4712 KB |
Output is correct |
24 |
Correct |
61 ms |
3668 KB |
Output is correct |
25 |
Correct |
88 ms |
5100 KB |
Output is correct |
26 |
Correct |
75 ms |
4956 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 |
4 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
312 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
99 ms |
5208 KB |
Output is correct |
35 |
Correct |
96 ms |
5020 KB |
Output is correct |
36 |
Correct |
102 ms |
5412 KB |
Output is correct |
37 |
Correct |
110 ms |
5572 KB |
Output is correct |
38 |
Correct |
96 ms |
5440 KB |
Output is correct |
39 |
Correct |
61 ms |
3424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 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 |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
73 ms |
4704 KB |
Output is correct |
12 |
Correct |
49 ms |
3284 KB |
Output is correct |
13 |
Correct |
57 ms |
4044 KB |
Output is correct |
14 |
Correct |
72 ms |
4844 KB |
Output is correct |
15 |
Correct |
68 ms |
5016 KB |
Output is correct |
16 |
Correct |
64 ms |
4788 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
308 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
88 ms |
4912 KB |
Output is correct |
23 |
Correct |
75 ms |
4712 KB |
Output is correct |
24 |
Correct |
61 ms |
3668 KB |
Output is correct |
25 |
Correct |
88 ms |
5100 KB |
Output is correct |
26 |
Correct |
75 ms |
4956 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 |
4 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
312 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
99 ms |
5208 KB |
Output is correct |
35 |
Correct |
96 ms |
5020 KB |
Output is correct |
36 |
Correct |
102 ms |
5412 KB |
Output is correct |
37 |
Correct |
110 ms |
5572 KB |
Output is correct |
38 |
Correct |
96 ms |
5440 KB |
Output is correct |
39 |
Correct |
61 ms |
3424 KB |
Output is correct |
40 |
Correct |
3 ms |
340 KB |
Output is correct |
41 |
Correct |
4 ms |
452 KB |
Output is correct |
42 |
Correct |
3 ms |
468 KB |
Output is correct |
43 |
Correct |
4 ms |
468 KB |
Output is correct |
44 |
Correct |
132 ms |
5920 KB |
Output is correct |
45 |
Correct |
133 ms |
5992 KB |
Output is correct |
46 |
Correct |
136 ms |
6148 KB |
Output is correct |
47 |
Correct |
133 ms |
6068 KB |
Output is correct |
48 |
Correct |
110 ms |
5908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
228 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
312 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 |
308 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 |
312 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 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 |
5 ms |
460 KB |
Output is correct |
27 |
Correct |
6 ms |
468 KB |
Output is correct |
28 |
Correct |
6 ms |
468 KB |
Output is correct |
29 |
Correct |
6 ms |
448 KB |
Output is correct |
30 |
Correct |
3 ms |
340 KB |
Output is correct |
31 |
Correct |
4 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
448 KB |
Output is correct |
33 |
Correct |
5 ms |
452 KB |
Output is correct |
34 |
Correct |
6 ms |
476 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
3 ms |
444 KB |
Output is correct |
38 |
Correct |
5 ms |
400 KB |
Output is correct |
39 |
Correct |
2 ms |
340 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
0 ms |
308 KB |
Output is correct |
48 |
Correct |
1 ms |
340 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
73 ms |
4704 KB |
Output is correct |
51 |
Correct |
49 ms |
3284 KB |
Output is correct |
52 |
Correct |
57 ms |
4044 KB |
Output is correct |
53 |
Correct |
72 ms |
4844 KB |
Output is correct |
54 |
Correct |
68 ms |
5016 KB |
Output is correct |
55 |
Correct |
64 ms |
4788 KB |
Output is correct |
56 |
Correct |
0 ms |
212 KB |
Output is correct |
57 |
Correct |
0 ms |
308 KB |
Output is correct |
58 |
Correct |
0 ms |
212 KB |
Output is correct |
59 |
Correct |
1 ms |
340 KB |
Output is correct |
60 |
Correct |
2 ms |
316 KB |
Output is correct |
61 |
Correct |
88 ms |
4912 KB |
Output is correct |
62 |
Correct |
75 ms |
4712 KB |
Output is correct |
63 |
Correct |
61 ms |
3668 KB |
Output is correct |
64 |
Correct |
88 ms |
5100 KB |
Output is correct |
65 |
Correct |
75 ms |
4956 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 |
4 ms |
468 KB |
Output is correct |
71 |
Correct |
1 ms |
312 KB |
Output is correct |
72 |
Correct |
1 ms |
340 KB |
Output is correct |
73 |
Correct |
99 ms |
5208 KB |
Output is correct |
74 |
Correct |
96 ms |
5020 KB |
Output is correct |
75 |
Correct |
102 ms |
5412 KB |
Output is correct |
76 |
Correct |
110 ms |
5572 KB |
Output is correct |
77 |
Correct |
96 ms |
5440 KB |
Output is correct |
78 |
Correct |
61 ms |
3424 KB |
Output is correct |
79 |
Correct |
3 ms |
340 KB |
Output is correct |
80 |
Correct |
4 ms |
452 KB |
Output is correct |
81 |
Correct |
3 ms |
468 KB |
Output is correct |
82 |
Correct |
4 ms |
468 KB |
Output is correct |
83 |
Correct |
132 ms |
5920 KB |
Output is correct |
84 |
Correct |
133 ms |
5992 KB |
Output is correct |
85 |
Correct |
136 ms |
6148 KB |
Output is correct |
86 |
Correct |
133 ms |
6068 KB |
Output is correct |
87 |
Correct |
110 ms |
5908 KB |
Output is correct |
88 |
Correct |
193 ms |
7820 KB |
Output is correct |
89 |
Correct |
197 ms |
7816 KB |
Output is correct |
90 |
Correct |
196 ms |
7812 KB |
Output is correct |
91 |
Correct |
208 ms |
7780 KB |
Output is correct |
92 |
Correct |
146 ms |
6376 KB |
Output is correct |
93 |
Correct |
162 ms |
6732 KB |
Output is correct |
94 |
Correct |
165 ms |
6572 KB |
Output is correct |
95 |
Correct |
171 ms |
7664 KB |
Output is correct |
96 |
Correct |
197 ms |
7816 KB |
Output is correct |
97 |
Correct |
172 ms |
7860 KB |
Output is correct |
98 |
Correct |
123 ms |
6280 KB |
Output is correct |
99 |
Correct |
176 ms |
6456 KB |
Output is correct |