#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, M;
ll D;
vector<ll> arr;
int cnt = 0;
struct segtree {
ll lt[808080], rt[808080], mx[808080], sum[808080];
void update(int v, int st, int ed, int idx, ll val) {
if (st > idx || ed < idx) return;
if (st == ed) {
lt[v] = rt[v] = mx[v] = sum[v] = val;
return;
}
int mid = (st+ed)/2;
update(2*v, st, mid, idx, val);
update(2*v+1, mid+1, ed, idx, val);
if (sum[2*v] > 0) lt[v] = max(lt[2*v], lt[2*v+1] + sum[2*v]);
else lt[v] = lt[2*v];
if (sum[2*v+1] > 0) rt[v] = max(rt[2*v+1], rt[2*v] + sum[2*v+1]);
else rt[v] = rt[2*v+1];
mx[v] = max(mx[2*v], mx[2*v+1]);
mx[v] = max(mx[v], rt[2*v]+lt[2*v+1]);
sum[v] = sum[2*v] + sum[2*v+1];
}
} seg;
int main() {
ios_base::sync_with_stdio(false);
cin.tie();
cin >> N >> M >> D;
for (int i = 1; i <= M; i++) {
ll a;
cin >> a;
if (i > 1) seg.update(1, 1, M, i, D - (a-arr.back()));
ll ans = seg.mx[1];
if (ans%2) cout << ans/2 << ".5 ";
else cout << ans/2 << " ";
arr.push_back(a);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
313 ms |
25828 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
313 ms |
25828 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |