이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll lr[200001][2];
priority_queue<pair<ll, ll>> pq;
int main() {
int n, q;
ll x, xt, w, cu = 0, ml = 0, mr = 0;
cin >> n >> q;
cin >> xt;
for (int i = 1; i < n; i++) {
cin >> x;
pq.push(make_pair(xt - x, i));
xt = x;
}
for (int i = 0; i < q; i++) {
cin >> w;
cu += w;
if (cu < ml) {
ml = cu;
while (!pq.empty() && -pq.top().first <= mr - ml) {
lr[pq.top().second][0] = -pq.top().first - mr;
lr[pq.top().second - 1][1] = mr;
pq.pop();
}
}
if (cu > mr) {
mr = cu;
while (!pq.empty() && -pq.top().first < mr - ml) {
lr[pq.top().second][0] = -ml;
lr[pq.top().second - 1][1] = ml - pq.top().first;
pq.pop();
}
}
}
while (!pq.empty()) {
lr[pq.top().second][0] = -ml;
lr[pq.top().second - 1][1] = mr;
pq.pop();
}
lr[0][0] = -ml;
lr[n - 1][1] = mr;
for (int i = 0; i < n; i++) {
cout << lr[i][0] + lr[i][1] << '\n';
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |