#include <stdio.h>
#define N 150000
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int *ww;
void sort(int *ii, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
while (j < k)
if (ww[ii[j]] == ww[i_])
j++;
else if (ww[ii[j]] < ww[i_]) {
tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
i++, j++;
} else {
k--;
tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
}
sort(ii, l, i);
l = k;
}
}
int main() {
static int xx[N], yy[N], zz[N], ii[N], jj[N], kk[N];
static char deleted[N];
int n, i, i_, j, j_, k, k_;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d%d%d", &xx[i], &yy[i], &zz[i]);
for (i = 0; i < n; i++)
ii[i] = jj[i] = kk[i] = i;
ww = xx, sort(ii, 0, n);
ww = yy, sort(jj, 0, n);
ww = zz, sort(kk, 0, n);
i = n - 1, j = n - 1, k = n - 1;
while (1) {
i_ = j_ = k_ = -1;
while (i >= 0 && deleted[i_ = ii[i]])
i--;
while (j >= 0 && deleted[j_ = jj[j]])
j--;
while (k >= 0 && deleted[k_ = kk[k]])
k--;
if (i < 0) {
printf("-1\n");
return 0;
}
if (yy[i_] >= yy[j_] || zz[i_] >= zz[k_])
deleted[i_] = 1;
else if (zz[j_] >= zz[k_] || xx[j_] >= xx[i_])
deleted[j_] = 1;
else if (xx[k_] >= xx[i_] || yy[k_] >= yy[j_])
deleted[k_] = 1;
else {
printf("%d\n", xx[i_] + yy[j_] + zz[k_]);
return 0;
}
}
return 0;
}
Compilation message
team.c: In function 'main':
team.c:37:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
team.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d%d%d", &xx[i], &yy[i], &zz[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
296 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
296 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
1 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 |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
308 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 |
420 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 |
436 KB |
Output is correct |
38 |
Correct |
3 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
34 ms |
3876 KB |
Output is correct |
12 |
Correct |
23 ms |
2776 KB |
Output is correct |
13 |
Correct |
24 ms |
3332 KB |
Output is correct |
14 |
Correct |
40 ms |
3980 KB |
Output is correct |
15 |
Correct |
43 ms |
3944 KB |
Output is correct |
16 |
Correct |
32 ms |
4044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
34 ms |
3876 KB |
Output is correct |
12 |
Correct |
23 ms |
2776 KB |
Output is correct |
13 |
Correct |
24 ms |
3332 KB |
Output is correct |
14 |
Correct |
40 ms |
3980 KB |
Output is correct |
15 |
Correct |
43 ms |
3944 KB |
Output is correct |
16 |
Correct |
32 ms |
4044 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
40 ms |
3892 KB |
Output is correct |
23 |
Correct |
38 ms |
3968 KB |
Output is correct |
24 |
Correct |
30 ms |
3008 KB |
Output is correct |
25 |
Correct |
44 ms |
4048 KB |
Output is correct |
26 |
Correct |
38 ms |
3960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
34 ms |
3876 KB |
Output is correct |
12 |
Correct |
23 ms |
2776 KB |
Output is correct |
13 |
Correct |
24 ms |
3332 KB |
Output is correct |
14 |
Correct |
40 ms |
3980 KB |
Output is correct |
15 |
Correct |
43 ms |
3944 KB |
Output is correct |
16 |
Correct |
32 ms |
4044 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
40 ms |
3892 KB |
Output is correct |
23 |
Correct |
38 ms |
3968 KB |
Output is correct |
24 |
Correct |
30 ms |
3008 KB |
Output is correct |
25 |
Correct |
44 ms |
4048 KB |
Output is correct |
26 |
Correct |
38 ms |
3960 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
300 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 |
54 ms |
3776 KB |
Output is correct |
35 |
Correct |
47 ms |
3712 KB |
Output is correct |
36 |
Correct |
55 ms |
4064 KB |
Output is correct |
37 |
Correct |
69 ms |
4036 KB |
Output is correct |
38 |
Correct |
37 ms |
3984 KB |
Output is correct |
39 |
Correct |
22 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
300 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
34 ms |
3876 KB |
Output is correct |
12 |
Correct |
23 ms |
2776 KB |
Output is correct |
13 |
Correct |
24 ms |
3332 KB |
Output is correct |
14 |
Correct |
40 ms |
3980 KB |
Output is correct |
15 |
Correct |
43 ms |
3944 KB |
Output is correct |
16 |
Correct |
32 ms |
4044 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
40 ms |
3892 KB |
Output is correct |
23 |
Correct |
38 ms |
3968 KB |
Output is correct |
24 |
Correct |
30 ms |
3008 KB |
Output is correct |
25 |
Correct |
44 ms |
4048 KB |
Output is correct |
26 |
Correct |
38 ms |
3960 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
300 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 |
54 ms |
3776 KB |
Output is correct |
35 |
Correct |
47 ms |
3712 KB |
Output is correct |
36 |
Correct |
55 ms |
4064 KB |
Output is correct |
37 |
Correct |
69 ms |
4036 KB |
Output is correct |
38 |
Correct |
37 ms |
3984 KB |
Output is correct |
39 |
Correct |
22 ms |
2552 KB |
Output is correct |
40 |
Correct |
2 ms |
308 KB |
Output is correct |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
1 ms |
468 KB |
Output is correct |
43 |
Correct |
2 ms |
468 KB |
Output is correct |
44 |
Correct |
70 ms |
3920 KB |
Output is correct |
45 |
Correct |
88 ms |
4136 KB |
Output is correct |
46 |
Correct |
69 ms |
4048 KB |
Output is correct |
47 |
Correct |
75 ms |
3996 KB |
Output is correct |
48 |
Correct |
49 ms |
4044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
296 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
1 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 |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
308 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 |
420 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 |
436 KB |
Output is correct |
38 |
Correct |
3 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
0 ms |
300 KB |
Output is correct |
46 |
Correct |
0 ms |
212 KB |
Output is correct |
47 |
Correct |
1 ms |
212 KB |
Output is correct |
48 |
Correct |
0 ms |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
34 ms |
3876 KB |
Output is correct |
51 |
Correct |
23 ms |
2776 KB |
Output is correct |
52 |
Correct |
24 ms |
3332 KB |
Output is correct |
53 |
Correct |
40 ms |
3980 KB |
Output is correct |
54 |
Correct |
43 ms |
3944 KB |
Output is correct |
55 |
Correct |
32 ms |
4044 KB |
Output is correct |
56 |
Correct |
1 ms |
296 KB |
Output is correct |
57 |
Correct |
0 ms |
212 KB |
Output is correct |
58 |
Correct |
0 ms |
212 KB |
Output is correct |
59 |
Correct |
1 ms |
340 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
40 ms |
3892 KB |
Output is correct |
62 |
Correct |
38 ms |
3968 KB |
Output is correct |
63 |
Correct |
30 ms |
3008 KB |
Output is correct |
64 |
Correct |
44 ms |
4048 KB |
Output is correct |
65 |
Correct |
38 ms |
3960 KB |
Output is correct |
66 |
Correct |
1 ms |
340 KB |
Output is correct |
67 |
Correct |
1 ms |
212 KB |
Output is correct |
68 |
Correct |
1 ms |
300 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 |
54 ms |
3776 KB |
Output is correct |
74 |
Correct |
47 ms |
3712 KB |
Output is correct |
75 |
Correct |
55 ms |
4064 KB |
Output is correct |
76 |
Correct |
69 ms |
4036 KB |
Output is correct |
77 |
Correct |
37 ms |
3984 KB |
Output is correct |
78 |
Correct |
22 ms |
2552 KB |
Output is correct |
79 |
Correct |
2 ms |
308 KB |
Output is correct |
80 |
Correct |
2 ms |
468 KB |
Output is correct |
81 |
Correct |
1 ms |
468 KB |
Output is correct |
82 |
Correct |
2 ms |
468 KB |
Output is correct |
83 |
Correct |
70 ms |
3920 KB |
Output is correct |
84 |
Correct |
88 ms |
4136 KB |
Output is correct |
85 |
Correct |
69 ms |
4048 KB |
Output is correct |
86 |
Correct |
75 ms |
3996 KB |
Output is correct |
87 |
Correct |
49 ms |
4044 KB |
Output is correct |
88 |
Correct |
103 ms |
3888 KB |
Output is correct |
89 |
Correct |
100 ms |
4168 KB |
Output is correct |
90 |
Correct |
99 ms |
4052 KB |
Output is correct |
91 |
Correct |
104 ms |
3992 KB |
Output is correct |
92 |
Correct |
87 ms |
4020 KB |
Output is correct |
93 |
Correct |
94 ms |
4048 KB |
Output is correct |
94 |
Correct |
88 ms |
4044 KB |
Output is correct |
95 |
Correct |
62 ms |
4048 KB |
Output is correct |
96 |
Correct |
111 ms |
4048 KB |
Output is correct |
97 |
Correct |
38 ms |
4024 KB |
Output is correct |
98 |
Correct |
53 ms |
3924 KB |
Output is correct |
99 |
Correct |
55 ms |
4036 KB |
Output is correct |