#include<bits/stdc++.h>
#define task "C"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define int long long
using namespace std;
const int MAXN = 2e5 + 5;
const ll INF = 1e18 + 5;
int n, q;
ll x[MAXN];
void Input()
{
cin >> n >> q;
for (int i = 1; i <= n; i++)
{
cin >> x[i];
}
}
int cs[MAXN], l[MAXN], r[MAXN];
void Solve()
{
x[0] = -INF;
iota(cs + 1, cs + 1 + n, 1);
sort(cs + 1, cs + 1 + n, [](int i, int j)
{
return x[i] - x[i - 1] < x[j] - x[j - 1];
});
int i = 1;
ll cur = 0, maxl = 0, maxr = 0;
while (q-- > 0)
{
ll w;
cin >> w;
cur += w;
maxr = max(maxr, cur);
maxl = min(maxl, cur);
for (; i <= n && x[cs[i]] - x[cs[i] - 1] <= maxr - maxl; i++)
{
if (w < 0)
{
r[cs[i] - 1] = x[cs[i] - 1] + maxr;
l[cs[i]] = x[cs[i] - 1] + maxr;
} else
{
if (cs[i] == 3)
cout << w << '\n';
r[cs[i] - 1] = x[cs[i]] + maxl;
l[cs[i]] = x[cs[i]] + maxl;
}
}
}
for (; i <= n; i++)
{
r[cs[i] - 1] = x[cs[i] - 1] + maxr;
l[cs[i]] = x[cs[i]] + maxl;
}
//r[cs[n]] = x[cs[n]] + maxr;
r[n] = x[n] + maxr;
l[1] = x[1] + maxl;
//cout << r[2] << '\n';
for (int i = 1; i <= n; i++)
{
cout << r[i] - l[i] << '\n';
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
Input();
Solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |