#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define Size(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}
const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 2e5 + 7;
const ll oo = 1e18 + 69;
int n, q;
ll x[maxn], w, res[maxn];
vector<pall> val;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(TASK".inp", "r", stdin);
//freopen(TASK".out", "w", stdout);
cin>>n>>q;
for(int i = 1; i <= n; i++) cin>>x[i];
for(int i = 2; i <= n; i++) val.pb({x[i] - x[i - 1], i});
sort(all(val));
ll l = 0, r = 0, cnt = 0;
int i = 0;
while(q--) {
cin>>w;
cnt += w;
if(cnt > 0) maxi(r, cnt);
if(cnt < 0) maxi(l, -cnt);
while(i < Size(val) && val[i].fi <= l + r) {
int j = val[i].se - 1;
if(cnt > 0) {
res[j] += val[i].fi - l;
res[j + 1] += l;
} else {
res[j] += r;
res[j + 1] += val[i].fi - r;
}
i++;
}
}
res[1] += l;
res[n] += r;
for(int i = 1; i <= n; i++) cout<<res[i]<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |