#include <stdio.h>
#define N 150000
double max(double a, double b) { return a > b ? a : b; }
int main() {
static int xx[N + 1], yy[N], ll[N], rr[N], pp[N], qu[N], dd[N], kk[N];
static double tt[N];
int n, k, cnt, i, i_, p, lower, upper, x;
long long area;
scanf("%d%*d%*d", &n), n = n / 2 - 1;
xx[0] = 0;
for (i = 0; i < n; i++)
scanf("%*d%*d%d%d", &xx[i + 1], &yy[i]);
scanf("%*d%*d");
cnt = 0;
for (i = 0; i < n; i++) {
while (cnt && yy[qu[cnt - 1]] > yy[i])
cnt--;
ll[i] = cnt == 0 ? -1 : qu[cnt - 1];
qu[cnt++] = i;
}
cnt = 0;
for (i = n - 1; i >= 0; i--) {
while (cnt && yy[qu[cnt - 1]] >= yy[i])
cnt--;
rr[i] = cnt == 0 ? n : qu[cnt - 1];
qu[cnt++] = i;
}
for (i = 0; i < n; i++) {
pp[i] = rr[i] == n || ll[i] != -1 && yy[ll[i]] > yy[rr[i]] ? ll[i] : rr[i];
if (pp[i] != -1)
dd[pp[i]]++;
}
scanf("%d", &k);
while (k--) {
scanf("%d%*d%*d%*d", &x);
lower = 0, upper = n;
while (upper - lower > 1) {
i = (lower + upper) / 2;
if (xx[i] <= x)
lower = i;
else
upper = i;
}
kk[lower]++;
}
for (i = 0; i < n; i++) {
i_ = i;
while (dd[i_] == 0) {
p = pp[i_];
if (kk[i_] > 0)
tt[i_] += (double) (xx[rr[i_]] - xx[ll[i_] + 1]) * (yy[i_] - (p == -1 ? 0 : yy[p])) / kk[i_];
dd[i_] = -1;
if (p == -1)
break;
kk[p] += kk[i_], tt[p] = max(tt[p], tt[i_]), dd[p]--, i_ = p;
}
}
for (i = 0; i < n; i++)
if (pp[i] == -1) {
printf("%.2f\n", tt[i]);
break;
}
area = 0;
for (i = 0; i < n; i++)
if (kk[i] == 0)
area += (long long) (xx[rr[i]] - xx[ll[i] + 1]) * (yy[i] - (pp[i] == -1 ? 0 : yy[pp[i]]));
printf("%lld\n", area);
return 0;
}
Compilation message
aqua2.c: In function 'main':
aqua2.c:33:37: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
33 | pp[i] = rr[i] == n || ll[i] != -1 && yy[ll[i]] > yy[rr[i]] ? ll[i] : rr[i];
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
aqua2.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d%*d%*d", &n), n = n / 2 - 1;
| ^~~~~~~~~~~~~~~~~~~~~
aqua2.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%*d%*d%d%d", &xx[i + 1], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aqua2.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | scanf("%*d%*d");
| ^~~~~~~~~~~~~~~
aqua2.c:37:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf("%d", &k);
| ^~~~~~~~~~~~~~~
aqua2.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d%*d%*d%*d", &x);
| ^~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 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 |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4528 KB |
Output is correct |
3 |
Correct |
1 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 |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4620 KB |
Output is correct |
5 |
Correct |
3 ms |
4440 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
9232 KB |
Output is correct |
2 |
Correct |
74 ms |
9484 KB |
Output is correct |
3 |
Correct |
89 ms |
9644 KB |
Output is correct |
4 |
Correct |
76 ms |
9516 KB |
Output is correct |
5 |
Correct |
83 ms |
10068 KB |
Output is correct |
6 |
Correct |
50 ms |
8528 KB |
Output is correct |
7 |
Correct |
82 ms |
10032 KB |
Output is correct |
8 |
Correct |
50 ms |
8940 KB |
Output is correct |
9 |
Correct |
78 ms |
9808 KB |
Output is correct |
10 |
Correct |
79 ms |
9616 KB |
Output is correct |