# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
945347 |
2024-03-13T16:33:15 Z |
rainboy |
Taxis (POI13_tak) |
C |
|
119 ms |
11612 KB |
#include <stdio.h>
#define N 500000
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
void sort(int *xx, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, x = xx[l + rand_() % (r - l)], tmp;
while (j < k)
if (xx[j] == x)
j++;
else if (xx[j] < x) {
tmp = xx[i], xx[i] = xx[j], xx[j] = tmp;
i++, j++;
} else {
k--;
tmp = xx[j], xx[j] = xx[k], xx[k] = tmp;
}
sort(xx, l, i);
l = k;
}
}
int main() {
static int xx[N];
int n, l, r, i, k;
scanf("%d%d%d", &r, &l, &n), r -= l;
for (i = 0; i < n; i++)
scanf("%d", &xx[i]);
sort(xx, 0, n);
k = 0;
if (r > 0) {
i = 0;
while (i < n && xx[i] < r)
i++;
if (i == n) {
printf("0\n");
return 0;
}
k++;
n--;
while (i < n)
xx[i] = xx[i + 1], i++;
}
for (i = n - 1; i >= 0 && l > 0; i--) {
if (l > xx[i]) {
printf("0\n");
return 0;
}
l -= xx[i] - l, k++;
}
printf("%d\n", k);
return 0;
}
Compilation message
tak.c: In function 'main':
tak.c:34:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | scanf("%d%d%d", &r, &l, &n), r -= l;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
tak.c:36:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%d", &xx[i]);
| ^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
424 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
860 KB |
Output is correct |
2 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
1372 KB |
Output is correct |
2 |
Incorrect |
14 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2140 KB |
Output is correct |
2 |
Incorrect |
47 ms |
4460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
5716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
11612 KB |
Output is correct |
2 |
Incorrect |
95 ms |
8788 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
105 ms |
11604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |