# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1044013 |
2024-08-05T06:23:09 Z |
ㄴㄴ(#11063) |
Measures (CEOI22_measures) |
C++17 |
|
316 ms |
26908 KB |
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
const ll INF = 1e18;
struct node {
ll l, r, v;
int c;
} T[535353];
ll L[535353];
const node EMP = {INF, -INF, 0, 0};
node operator +(node p, node q) {
node ret;
ret.l = min(p.l, q.l);
ret.r = max(p.r, q.r);
ret.v = max({p.v, q.v, p.r - q.l});
ret.c = p.c + q.c;
return ret;
}
void push(int idx, int s, int e) {
if(L[idx]) {
T[idx].l += L[idx];
T[idx].r += L[idx];
if(s != e) {
L[idx*2] += L[idx];
L[idx*2+1] += L[idx];
}
L[idx] = 0;
}
}
node get(int idx, int s, int e, int l, int r) {
push(idx, s, e);
if(r < s || e < l) return EMP;
if(l <= s && e <= r) return T[idx];
int m = s+e >> 1;
return get(idx*2, s, m, l, r) + get(idx*2+1, m+1, e, l, r);
}
void upd(int idx, int s, int e, int l, int r, int v) {
push(idx, s, e);
if(r < s || e < l) return;
if(l <= s && e <= r) {
L[idx] += v;
push(idx, s, e);
return;
}
int m = s+e >> 1;
upd(idx*2, s, m, l, r, v);
upd(idx*2+1, m+1, e, l, r, v);
T[idx] = T[idx*2] + T[idx*2+1];
}
void add(int idx, int s, int e, int p, node v) {
push(idx, s, e);
if(p < s || e < p) return;
if(s == e) {
T[idx] = v;
return;
}
int m = s+e >> 1;
add(idx*2, s, m, p, v);
add(idx*2+1, m+1, e, p, v);
T[idx] = T[idx*2] + T[idx*2+1];
}
int I[202020];
int main() {
int N, M, D; scanf("%d%d%d", &N, &M, &D);
for(int i=0; i<535353; i++) T[i] = EMP;
vector<pii> A(N+M);
for(int i=0; i<N+M; i++) {
scanf("%d", &A[i].first);
A[i].second = i;
}
sort(A.begin(), A.end());
for(int i=0; i<N+M; i++) I[A[i].second] = i+1;
sort(A.begin(), A.end(), [&](pii p, pii q) { return p.second < q.second; });
for(int i=0; i<N+M; i++) {
auto [x, y] = A[i];
int j = get(1, 1, N+M, 1, I[y]).c;
upd(1, 1, N+M, I[y], N+M, -D);
add(1, 1, N+M, I[y], {x - 1LL*D*j, x - 1LL*D*j, 0, 1});
if(i >= N) {
ll ans = get(1, 1, N+M, 1, N+M).v;
if(ans % 2) printf("%lld.5 ", ans / 2);
else printf("%lld ", ans / 2);
}
}
return 0;
}
Compilation message
Main.cpp: In function 'node get(int, int, int, int, int)':
Main.cpp:39:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
39 | int m = s+e >> 1;
| ~^~
Main.cpp: In function 'void upd(int, int, int, int, int, int)':
Main.cpp:51:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
51 | int m = s+e >> 1;
| ~^~
Main.cpp: In function 'void add(int, int, int, int, node)':
Main.cpp:64:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
64 | int m = s+e >> 1;
| ~^~
Main.cpp: In function 'int main()':
Main.cpp:73:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
73 | int N, M, D; scanf("%d%d%d", &N, &M, &D);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:77:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
77 | scanf("%d", &A[i].first);
| ~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
17752 KB |
Output is correct |
2 |
Correct |
3 ms |
17756 KB |
Output is correct |
3 |
Correct |
4 ms |
17964 KB |
Output is correct |
4 |
Correct |
3 ms |
17756 KB |
Output is correct |
5 |
Correct |
3 ms |
17756 KB |
Output is correct |
6 |
Correct |
3 ms |
17756 KB |
Output is correct |
7 |
Correct |
4 ms |
17756 KB |
Output is correct |
8 |
Correct |
4 ms |
17756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
17752 KB |
Output is correct |
2 |
Correct |
3 ms |
17756 KB |
Output is correct |
3 |
Correct |
4 ms |
17964 KB |
Output is correct |
4 |
Correct |
3 ms |
17756 KB |
Output is correct |
5 |
Correct |
3 ms |
17756 KB |
Output is correct |
6 |
Correct |
3 ms |
17756 KB |
Output is correct |
7 |
Correct |
4 ms |
17756 KB |
Output is correct |
8 |
Correct |
4 ms |
17756 KB |
Output is correct |
9 |
Correct |
280 ms |
23732 KB |
Output is correct |
10 |
Correct |
265 ms |
23484 KB |
Output is correct |
11 |
Correct |
178 ms |
23636 KB |
Output is correct |
12 |
Correct |
219 ms |
23632 KB |
Output is correct |
13 |
Correct |
208 ms |
23648 KB |
Output is correct |
14 |
Correct |
211 ms |
23636 KB |
Output is correct |
15 |
Correct |
284 ms |
23812 KB |
Output is correct |
16 |
Correct |
202 ms |
23732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
24596 KB |
Output is correct |
2 |
Correct |
217 ms |
26452 KB |
Output is correct |
3 |
Correct |
208 ms |
26432 KB |
Output is correct |
4 |
Correct |
204 ms |
24388 KB |
Output is correct |
5 |
Correct |
208 ms |
25708 KB |
Output is correct |
6 |
Correct |
211 ms |
24676 KB |
Output is correct |
7 |
Correct |
205 ms |
25752 KB |
Output is correct |
8 |
Correct |
205 ms |
24384 KB |
Output is correct |
9 |
Correct |
206 ms |
24356 KB |
Output is correct |
10 |
Correct |
218 ms |
26900 KB |
Output is correct |
11 |
Correct |
197 ms |
25284 KB |
Output is correct |
12 |
Correct |
204 ms |
26140 KB |
Output is correct |
13 |
Correct |
207 ms |
24388 KB |
Output is correct |
14 |
Correct |
199 ms |
26452 KB |
Output is correct |
15 |
Correct |
206 ms |
26188 KB |
Output is correct |
16 |
Correct |
197 ms |
24304 KB |
Output is correct |
17 |
Correct |
201 ms |
25936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
24596 KB |
Output is correct |
2 |
Correct |
217 ms |
26452 KB |
Output is correct |
3 |
Correct |
208 ms |
26432 KB |
Output is correct |
4 |
Correct |
204 ms |
24388 KB |
Output is correct |
5 |
Correct |
208 ms |
25708 KB |
Output is correct |
6 |
Correct |
211 ms |
24676 KB |
Output is correct |
7 |
Correct |
205 ms |
25752 KB |
Output is correct |
8 |
Correct |
205 ms |
24384 KB |
Output is correct |
9 |
Correct |
206 ms |
24356 KB |
Output is correct |
10 |
Correct |
218 ms |
26900 KB |
Output is correct |
11 |
Correct |
197 ms |
25284 KB |
Output is correct |
12 |
Correct |
204 ms |
26140 KB |
Output is correct |
13 |
Correct |
207 ms |
24388 KB |
Output is correct |
14 |
Correct |
199 ms |
26452 KB |
Output is correct |
15 |
Correct |
206 ms |
26188 KB |
Output is correct |
16 |
Correct |
197 ms |
24304 KB |
Output is correct |
17 |
Correct |
201 ms |
25936 KB |
Output is correct |
18 |
Correct |
263 ms |
24916 KB |
Output is correct |
19 |
Correct |
245 ms |
26452 KB |
Output is correct |
20 |
Correct |
195 ms |
26508 KB |
Output is correct |
21 |
Correct |
222 ms |
24660 KB |
Output is correct |
22 |
Correct |
230 ms |
24900 KB |
Output is correct |
23 |
Correct |
209 ms |
24656 KB |
Output is correct |
24 |
Correct |
256 ms |
25168 KB |
Output is correct |
25 |
Correct |
198 ms |
24496 KB |
Output is correct |
26 |
Correct |
256 ms |
24344 KB |
Output is correct |
27 |
Correct |
269 ms |
26908 KB |
Output is correct |
28 |
Correct |
250 ms |
24716 KB |
Output is correct |
29 |
Correct |
261 ms |
26148 KB |
Output is correct |
30 |
Correct |
230 ms |
24400 KB |
Output is correct |
31 |
Correct |
273 ms |
26376 KB |
Output is correct |
32 |
Correct |
230 ms |
26192 KB |
Output is correct |
33 |
Correct |
316 ms |
24480 KB |
Output is correct |
34 |
Correct |
276 ms |
25680 KB |
Output is correct |