| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 935439 | weakweakweak | Snowball (JOI21_ho_t2) | C++14 | 71 ms | 15016 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fs first
#define sc second
int n, a[210000], ans[210000] = {0}, q;
vector<pii>pp;
signed main () {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i > 1) pp.push_back({a[i] - a[i - 1], i - 1});
}
pp.push_back({LLONG_MAX - 2, 0}); pp.push_back({LLONG_MAX - 2, n});
sort(pp.begin(), pp.end());
int now = 0, l = 0, r = 0, x, stkf = 0;
while (q -- ) {
cin >> x;
now += x;
int oldl = l, oldr = r;
if (now < 0) l = max(l, -now);
if (now > 0) r = max(r, now);
while (stkf < pp.size() and l + r >= pp[stkf].fs) {
ans[pp[stkf].sc] += oldr, ans[pp[stkf].sc + 1] += oldl;
pp[stkf].fs -= oldl + oldr;
if (now < 0) ans[pp[stkf].sc + 1] += pp[stkf].fs;
else ans[pp[stkf].sc] += pp[stkf].fs;
stkf++;
}
}
while (stkf < pp.size()) {
ans[pp[stkf].sc] += r, ans[pp[stkf].sc + 1] += l;
stkf++;
}
for (int i = 1; i <= n; i++) cout << ans[i] << '\n';
return 0;}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
