# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
596176 |
2022-07-14T12:56:37 Z |
jk410 |
Team Contest (JOI22_team) |
C++17 |
|
103 ms |
9848 KB |
#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int N;
int X[150001],Y[150001],Z[150001];
vector<pair<int,int>> VX,VY,VZ;
bool Used[150001];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N;
for (int i=1; i<=N; i++){
cin>>X[i]>>Y[i]>>Z[i];
VX.push_back({X[i],i});
VY.push_back({Y[i],i});
VZ.push_back({Z[i],i});
}
sort(all(VX));
sort(all(VY));
sort(all(VZ));
for (int x=N-1,y=N-1,z=N-1; x>=0&&y>=0&&z>=0;){
if (Y[VX[x].second]==VY[y].first||Z[VX[x].second]==VZ[z].first)
Used[VX[x].second]=true;
else if (X[VY[y].second]==VX[x].first||Z[VY[y].second]==VZ[z].first)
Used[VY[y].second]=true;
else if (X[VZ[z].second]==VX[x].first||Y[VZ[z].second]==VY[y].first)
Used[VZ[z].second]=true;
else{
cout<<VX[x].first+VY[y].first+VZ[z].first;
return 0;
}
while (x>=0&&Used[VX[x].second])
x--;
while (y>=0&&Used[VY[y].second])
y--;
while (z>=0&&Used[VZ[z].second])
z--;
}
cout<<"-1";
return 0;
}
# |
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 |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
336 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 |
0 ms |
336 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 |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
336 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 |
0 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
3 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
3 ms |
596 KB |
Output is correct |
30 |
Correct |
2 ms |
476 KB |
Output is correct |
31 |
Correct |
2 ms |
472 KB |
Output is correct |
32 |
Correct |
3 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
596 KB |
Output is correct |
34 |
Correct |
2 ms |
596 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
2 ms |
560 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 |
332 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 |
1 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 |
336 KB |
Output is correct |
11 |
Correct |
64 ms |
6908 KB |
Output is correct |
12 |
Correct |
42 ms |
4660 KB |
Output is correct |
13 |
Correct |
44 ms |
5548 KB |
Output is correct |
14 |
Correct |
67 ms |
7020 KB |
Output is correct |
15 |
Correct |
61 ms |
6916 KB |
Output is correct |
16 |
Correct |
40 ms |
7108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 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 |
1 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 |
336 KB |
Output is correct |
11 |
Correct |
64 ms |
6908 KB |
Output is correct |
12 |
Correct |
42 ms |
4660 KB |
Output is correct |
13 |
Correct |
44 ms |
5548 KB |
Output is correct |
14 |
Correct |
67 ms |
7020 KB |
Output is correct |
15 |
Correct |
61 ms |
6916 KB |
Output is correct |
16 |
Correct |
40 ms |
7108 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
79 ms |
7228 KB |
Output is correct |
23 |
Correct |
71 ms |
6964 KB |
Output is correct |
24 |
Correct |
63 ms |
5104 KB |
Output is correct |
25 |
Correct |
75 ms |
7212 KB |
Output is correct |
26 |
Correct |
60 ms |
7068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 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 |
1 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 |
336 KB |
Output is correct |
11 |
Correct |
64 ms |
6908 KB |
Output is correct |
12 |
Correct |
42 ms |
4660 KB |
Output is correct |
13 |
Correct |
44 ms |
5548 KB |
Output is correct |
14 |
Correct |
67 ms |
7020 KB |
Output is correct |
15 |
Correct |
61 ms |
6916 KB |
Output is correct |
16 |
Correct |
40 ms |
7108 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
79 ms |
7228 KB |
Output is correct |
23 |
Correct |
71 ms |
6964 KB |
Output is correct |
24 |
Correct |
63 ms |
5104 KB |
Output is correct |
25 |
Correct |
75 ms |
7212 KB |
Output is correct |
26 |
Correct |
60 ms |
7068 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
2 ms |
476 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
86 ms |
7584 KB |
Output is correct |
35 |
Correct |
87 ms |
7564 KB |
Output is correct |
36 |
Correct |
78 ms |
7644 KB |
Output is correct |
37 |
Correct |
97 ms |
7708 KB |
Output is correct |
38 |
Correct |
63 ms |
7564 KB |
Output is correct |
39 |
Correct |
33 ms |
4636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 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 |
1 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 |
336 KB |
Output is correct |
11 |
Correct |
64 ms |
6908 KB |
Output is correct |
12 |
Correct |
42 ms |
4660 KB |
Output is correct |
13 |
Correct |
44 ms |
5548 KB |
Output is correct |
14 |
Correct |
67 ms |
7020 KB |
Output is correct |
15 |
Correct |
61 ms |
6916 KB |
Output is correct |
16 |
Correct |
40 ms |
7108 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
79 ms |
7228 KB |
Output is correct |
23 |
Correct |
71 ms |
6964 KB |
Output is correct |
24 |
Correct |
63 ms |
5104 KB |
Output is correct |
25 |
Correct |
75 ms |
7212 KB |
Output is correct |
26 |
Correct |
60 ms |
7068 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
2 ms |
476 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
86 ms |
7584 KB |
Output is correct |
35 |
Correct |
87 ms |
7564 KB |
Output is correct |
36 |
Correct |
78 ms |
7644 KB |
Output is correct |
37 |
Correct |
97 ms |
7708 KB |
Output is correct |
38 |
Correct |
63 ms |
7564 KB |
Output is correct |
39 |
Correct |
33 ms |
4636 KB |
Output is correct |
40 |
Correct |
2 ms |
468 KB |
Output is correct |
41 |
Correct |
2 ms |
472 KB |
Output is correct |
42 |
Correct |
2 ms |
468 KB |
Output is correct |
43 |
Correct |
2 ms |
468 KB |
Output is correct |
44 |
Correct |
76 ms |
8108 KB |
Output is correct |
45 |
Correct |
84 ms |
8084 KB |
Output is correct |
46 |
Correct |
80 ms |
8116 KB |
Output is correct |
47 |
Correct |
83 ms |
8108 KB |
Output is correct |
48 |
Correct |
86 ms |
7988 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 |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
336 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 |
0 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
3 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
3 ms |
596 KB |
Output is correct |
30 |
Correct |
2 ms |
476 KB |
Output is correct |
31 |
Correct |
2 ms |
472 KB |
Output is correct |
32 |
Correct |
3 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
596 KB |
Output is correct |
34 |
Correct |
2 ms |
596 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
2 ms |
560 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 |
332 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 |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
0 ms |
340 KB |
Output is correct |
48 |
Correct |
1 ms |
340 KB |
Output is correct |
49 |
Correct |
0 ms |
336 KB |
Output is correct |
50 |
Correct |
64 ms |
6908 KB |
Output is correct |
51 |
Correct |
42 ms |
4660 KB |
Output is correct |
52 |
Correct |
44 ms |
5548 KB |
Output is correct |
53 |
Correct |
67 ms |
7020 KB |
Output is correct |
54 |
Correct |
61 ms |
6916 KB |
Output is correct |
55 |
Correct |
40 ms |
7108 KB |
Output is correct |
56 |
Correct |
1 ms |
332 KB |
Output is correct |
57 |
Correct |
0 ms |
212 KB |
Output is correct |
58 |
Correct |
0 ms |
336 KB |
Output is correct |
59 |
Correct |
1 ms |
340 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
79 ms |
7228 KB |
Output is correct |
62 |
Correct |
71 ms |
6964 KB |
Output is correct |
63 |
Correct |
63 ms |
5104 KB |
Output is correct |
64 |
Correct |
75 ms |
7212 KB |
Output is correct |
65 |
Correct |
60 ms |
7068 KB |
Output is correct |
66 |
Correct |
0 ms |
340 KB |
Output is correct |
67 |
Correct |
0 ms |
332 KB |
Output is correct |
68 |
Correct |
1 ms |
340 KB |
Output is correct |
69 |
Correct |
1 ms |
332 KB |
Output is correct |
70 |
Correct |
2 ms |
476 KB |
Output is correct |
71 |
Correct |
1 ms |
348 KB |
Output is correct |
72 |
Correct |
1 ms |
340 KB |
Output is correct |
73 |
Correct |
86 ms |
7584 KB |
Output is correct |
74 |
Correct |
87 ms |
7564 KB |
Output is correct |
75 |
Correct |
78 ms |
7644 KB |
Output is correct |
76 |
Correct |
97 ms |
7708 KB |
Output is correct |
77 |
Correct |
63 ms |
7564 KB |
Output is correct |
78 |
Correct |
33 ms |
4636 KB |
Output is correct |
79 |
Correct |
2 ms |
468 KB |
Output is correct |
80 |
Correct |
2 ms |
472 KB |
Output is correct |
81 |
Correct |
2 ms |
468 KB |
Output is correct |
82 |
Correct |
2 ms |
468 KB |
Output is correct |
83 |
Correct |
76 ms |
8108 KB |
Output is correct |
84 |
Correct |
84 ms |
8084 KB |
Output is correct |
85 |
Correct |
80 ms |
8116 KB |
Output is correct |
86 |
Correct |
83 ms |
8108 KB |
Output is correct |
87 |
Correct |
86 ms |
7988 KB |
Output is correct |
88 |
Correct |
88 ms |
9652 KB |
Output is correct |
89 |
Correct |
103 ms |
9764 KB |
Output is correct |
90 |
Correct |
86 ms |
9704 KB |
Output is correct |
91 |
Correct |
102 ms |
9756 KB |
Output is correct |
92 |
Correct |
99 ms |
8380 KB |
Output is correct |
93 |
Correct |
86 ms |
8784 KB |
Output is correct |
94 |
Correct |
97 ms |
8468 KB |
Output is correct |
95 |
Correct |
87 ms |
9584 KB |
Output is correct |
96 |
Correct |
88 ms |
9732 KB |
Output is correct |
97 |
Correct |
60 ms |
9848 KB |
Output is correct |
98 |
Correct |
48 ms |
8536 KB |
Output is correct |
99 |
Correct |
73 ms |
8436 KB |
Output is correct |