# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
861729 |
2023-10-16T19:45:01 Z |
ziu |
Team Contest (JOI22_team) |
C++14 |
|
83 ms |
9808 KB |
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct bober {
int x[3];
int num;
};
int n, indexSort=0, ix = 0, iy = 0, iz = 0;
bool tab[150010];
bober tx[150010], ty[150010], tz[150010];
bool sortuj(bober& a, bober& b) {
return a.x[indexSort] > b.x[indexSort];
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> tx[i].x[0] >> tx[i].x[1] >> tx[i].x[2];
tx[i].num = i;
ty[i] = tx[i];
tz[i] = tx[i];
}
sort(tx, tx + n, sortuj);
indexSort++;
sort(ty, ty + n, sortuj);
indexSort++;
sort(tz, tz + n, sortuj);
while (ix < n && iy < n && iz < n) {
int maxx = tx[ix].x[0];
int maxy = ty[iy].x[1];
int maxz = tz[iz].x[2];
//cout << tx[ix].num << ' ' << ty[iy].num << ' ' << tz[iz].num << " : " << maxx << ' ' << maxy << ' ' << maxz << '\n';
if (tx[ix].x[1]==maxy||tx[ix].x[2]==maxz) {
tab[tx[ix].num] = true;
ix++;
}
else if (ty[iy].x[0] == maxx || ty[iy].x[2] == maxz) {
tab[ty[iy].num] = true;
iy++;
}
else if (tz[iz].x[1] == maxy || tz[iz].x[0] == maxx) {
tab[tz[iz].num] = true;
iz++;
}
else {
cout << maxx + maxy + maxz << '\n';
return 0;
}
while (ix < n && tab[tx[ix].num] == true) ix++;
while (iy < n && tab[ty[iy].num] == true) iy++;
while (iz < n && tab[tz[iz].num] == true) iz++;
}
cout << -1 << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4564 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4696 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4472 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4564 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4696 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4472 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
3 ms |
4696 KB |
Output is correct |
27 |
Correct |
3 ms |
4700 KB |
Output is correct |
28 |
Correct |
2 ms |
4728 KB |
Output is correct |
29 |
Correct |
3 ms |
4700 KB |
Output is correct |
30 |
Correct |
2 ms |
4648 KB |
Output is correct |
31 |
Correct |
3 ms |
4440 KB |
Output is correct |
32 |
Correct |
2 ms |
4576 KB |
Output is correct |
33 |
Correct |
2 ms |
4700 KB |
Output is correct |
34 |
Correct |
2 ms |
4700 KB |
Output is correct |
35 |
Correct |
1 ms |
4444 KB |
Output is correct |
36 |
Correct |
1 ms |
4444 KB |
Output is correct |
37 |
Correct |
2 ms |
4444 KB |
Output is correct |
38 |
Correct |
2 ms |
4640 KB |
Output is correct |
39 |
Correct |
1 ms |
4460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4456 KB |
Output is correct |
2 |
Correct |
1 ms |
4456 KB |
Output is correct |
3 |
Correct |
1 ms |
4456 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4452 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
37 ms |
8048 KB |
Output is correct |
12 |
Correct |
25 ms |
7256 KB |
Output is correct |
13 |
Correct |
27 ms |
7512 KB |
Output is correct |
14 |
Correct |
39 ms |
8276 KB |
Output is correct |
15 |
Correct |
41 ms |
8436 KB |
Output is correct |
16 |
Correct |
32 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4456 KB |
Output is correct |
2 |
Correct |
1 ms |
4456 KB |
Output is correct |
3 |
Correct |
1 ms |
4456 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4452 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
37 ms |
8048 KB |
Output is correct |
12 |
Correct |
25 ms |
7256 KB |
Output is correct |
13 |
Correct |
27 ms |
7512 KB |
Output is correct |
14 |
Correct |
39 ms |
8276 KB |
Output is correct |
15 |
Correct |
41 ms |
8436 KB |
Output is correct |
16 |
Correct |
32 ms |
8284 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4580 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
43 ms |
8168 KB |
Output is correct |
23 |
Correct |
40 ms |
8188 KB |
Output is correct |
24 |
Correct |
32 ms |
7516 KB |
Output is correct |
25 |
Correct |
48 ms |
8392 KB |
Output is correct |
26 |
Correct |
36 ms |
8272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4456 KB |
Output is correct |
2 |
Correct |
1 ms |
4456 KB |
Output is correct |
3 |
Correct |
1 ms |
4456 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4452 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
37 ms |
8048 KB |
Output is correct |
12 |
Correct |
25 ms |
7256 KB |
Output is correct |
13 |
Correct |
27 ms |
7512 KB |
Output is correct |
14 |
Correct |
39 ms |
8276 KB |
Output is correct |
15 |
Correct |
41 ms |
8436 KB |
Output is correct |
16 |
Correct |
32 ms |
8284 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4580 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
43 ms |
8168 KB |
Output is correct |
23 |
Correct |
40 ms |
8188 KB |
Output is correct |
24 |
Correct |
32 ms |
7516 KB |
Output is correct |
25 |
Correct |
48 ms |
8392 KB |
Output is correct |
26 |
Correct |
36 ms |
8272 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
2 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
1 ms |
4444 KB |
Output is correct |
34 |
Correct |
55 ms |
8400 KB |
Output is correct |
35 |
Correct |
49 ms |
8284 KB |
Output is correct |
36 |
Correct |
53 ms |
8532 KB |
Output is correct |
37 |
Correct |
54 ms |
8528 KB |
Output is correct |
38 |
Correct |
40 ms |
8528 KB |
Output is correct |
39 |
Correct |
24 ms |
7512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4456 KB |
Output is correct |
2 |
Correct |
1 ms |
4456 KB |
Output is correct |
3 |
Correct |
1 ms |
4456 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4452 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
37 ms |
8048 KB |
Output is correct |
12 |
Correct |
25 ms |
7256 KB |
Output is correct |
13 |
Correct |
27 ms |
7512 KB |
Output is correct |
14 |
Correct |
39 ms |
8276 KB |
Output is correct |
15 |
Correct |
41 ms |
8436 KB |
Output is correct |
16 |
Correct |
32 ms |
8284 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4580 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
43 ms |
8168 KB |
Output is correct |
23 |
Correct |
40 ms |
8188 KB |
Output is correct |
24 |
Correct |
32 ms |
7516 KB |
Output is correct |
25 |
Correct |
48 ms |
8392 KB |
Output is correct |
26 |
Correct |
36 ms |
8272 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
2 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
1 ms |
4444 KB |
Output is correct |
34 |
Correct |
55 ms |
8400 KB |
Output is correct |
35 |
Correct |
49 ms |
8284 KB |
Output is correct |
36 |
Correct |
53 ms |
8532 KB |
Output is correct |
37 |
Correct |
54 ms |
8528 KB |
Output is correct |
38 |
Correct |
40 ms |
8528 KB |
Output is correct |
39 |
Correct |
24 ms |
7512 KB |
Output is correct |
40 |
Correct |
2 ms |
4444 KB |
Output is correct |
41 |
Correct |
2 ms |
4676 KB |
Output is correct |
42 |
Correct |
2 ms |
4580 KB |
Output is correct |
43 |
Correct |
2 ms |
4444 KB |
Output is correct |
44 |
Correct |
63 ms |
8768 KB |
Output is correct |
45 |
Correct |
64 ms |
8768 KB |
Output is correct |
46 |
Correct |
64 ms |
8784 KB |
Output is correct |
47 |
Correct |
71 ms |
8788 KB |
Output is correct |
48 |
Correct |
45 ms |
8784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4564 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4696 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4472 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
3 ms |
4696 KB |
Output is correct |
27 |
Correct |
3 ms |
4700 KB |
Output is correct |
28 |
Correct |
2 ms |
4728 KB |
Output is correct |
29 |
Correct |
3 ms |
4700 KB |
Output is correct |
30 |
Correct |
2 ms |
4648 KB |
Output is correct |
31 |
Correct |
3 ms |
4440 KB |
Output is correct |
32 |
Correct |
2 ms |
4576 KB |
Output is correct |
33 |
Correct |
2 ms |
4700 KB |
Output is correct |
34 |
Correct |
2 ms |
4700 KB |
Output is correct |
35 |
Correct |
1 ms |
4444 KB |
Output is correct |
36 |
Correct |
1 ms |
4444 KB |
Output is correct |
37 |
Correct |
2 ms |
4444 KB |
Output is correct |
38 |
Correct |
2 ms |
4640 KB |
Output is correct |
39 |
Correct |
1 ms |
4460 KB |
Output is correct |
40 |
Correct |
1 ms |
4456 KB |
Output is correct |
41 |
Correct |
1 ms |
4456 KB |
Output is correct |
42 |
Correct |
1 ms |
4456 KB |
Output is correct |
43 |
Correct |
1 ms |
4572 KB |
Output is correct |
44 |
Correct |
1 ms |
4452 KB |
Output is correct |
45 |
Correct |
1 ms |
4444 KB |
Output is correct |
46 |
Correct |
1 ms |
4444 KB |
Output is correct |
47 |
Correct |
1 ms |
4444 KB |
Output is correct |
48 |
Correct |
1 ms |
4568 KB |
Output is correct |
49 |
Correct |
1 ms |
4444 KB |
Output is correct |
50 |
Correct |
37 ms |
8048 KB |
Output is correct |
51 |
Correct |
25 ms |
7256 KB |
Output is correct |
52 |
Correct |
27 ms |
7512 KB |
Output is correct |
53 |
Correct |
39 ms |
8276 KB |
Output is correct |
54 |
Correct |
41 ms |
8436 KB |
Output is correct |
55 |
Correct |
32 ms |
8284 KB |
Output is correct |
56 |
Correct |
1 ms |
4444 KB |
Output is correct |
57 |
Correct |
1 ms |
4444 KB |
Output is correct |
58 |
Correct |
1 ms |
4444 KB |
Output is correct |
59 |
Correct |
1 ms |
4580 KB |
Output is correct |
60 |
Correct |
1 ms |
4444 KB |
Output is correct |
61 |
Correct |
43 ms |
8168 KB |
Output is correct |
62 |
Correct |
40 ms |
8188 KB |
Output is correct |
63 |
Correct |
32 ms |
7516 KB |
Output is correct |
64 |
Correct |
48 ms |
8392 KB |
Output is correct |
65 |
Correct |
36 ms |
8272 KB |
Output is correct |
66 |
Correct |
1 ms |
4444 KB |
Output is correct |
67 |
Correct |
1 ms |
4444 KB |
Output is correct |
68 |
Correct |
1 ms |
4444 KB |
Output is correct |
69 |
Correct |
1 ms |
4444 KB |
Output is correct |
70 |
Correct |
2 ms |
4444 KB |
Output is correct |
71 |
Correct |
1 ms |
4444 KB |
Output is correct |
72 |
Correct |
1 ms |
4444 KB |
Output is correct |
73 |
Correct |
55 ms |
8400 KB |
Output is correct |
74 |
Correct |
49 ms |
8284 KB |
Output is correct |
75 |
Correct |
53 ms |
8532 KB |
Output is correct |
76 |
Correct |
54 ms |
8528 KB |
Output is correct |
77 |
Correct |
40 ms |
8528 KB |
Output is correct |
78 |
Correct |
24 ms |
7512 KB |
Output is correct |
79 |
Correct |
2 ms |
4444 KB |
Output is correct |
80 |
Correct |
2 ms |
4676 KB |
Output is correct |
81 |
Correct |
2 ms |
4580 KB |
Output is correct |
82 |
Correct |
2 ms |
4444 KB |
Output is correct |
83 |
Correct |
63 ms |
8768 KB |
Output is correct |
84 |
Correct |
64 ms |
8768 KB |
Output is correct |
85 |
Correct |
64 ms |
8784 KB |
Output is correct |
86 |
Correct |
71 ms |
8788 KB |
Output is correct |
87 |
Correct |
45 ms |
8784 KB |
Output is correct |
88 |
Correct |
78 ms |
9556 KB |
Output is correct |
89 |
Correct |
83 ms |
9788 KB |
Output is correct |
90 |
Correct |
79 ms |
9792 KB |
Output is correct |
91 |
Correct |
83 ms |
9792 KB |
Output is correct |
92 |
Correct |
76 ms |
9040 KB |
Output is correct |
93 |
Correct |
79 ms |
9028 KB |
Output is correct |
94 |
Correct |
75 ms |
9028 KB |
Output is correct |
95 |
Correct |
54 ms |
9556 KB |
Output is correct |
96 |
Correct |
79 ms |
9796 KB |
Output is correct |
97 |
Correct |
44 ms |
9808 KB |
Output is correct |
98 |
Correct |
46 ms |
8796 KB |
Output is correct |
99 |
Correct |
50 ms |
9020 KB |
Output is correct |