# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830465 | RaresFelix | Snowball (JOI21_ho_t2) | C++17 | 177 ms | 17044 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;
const int MN = 200001;
const int MQ = 200001;
using ll = long long;
ll P[MN], A[MQ], St[MN], Dr[MN];
int n, q;
vector<pair<ll, int> > Dist;
int main() {
cin >> n >> q;
for(int i = 1; i <= n; ++i) {
cin >> P[i];
St[i] = Dr[i] = -1;
}
for(int i = 1; i < n; ++i) {
Dist.push_back(make_pair(P[i + 1] - P[i], i));
}
sort(Dist.begin(), Dist.end());
ll itD = 0, st = 0, dr = 0, p = 0;
for(int i = 1; i <= q; ++i) {
cin >> A[i];
p += A[i];
if(p > dr) {
while(itD != Dist.size() && Dist[itD].first <= st + p) {
int acum = Dist[itD].second;
if(St[acum + 1] == -1)
St[acum + 1] = st;
if(Dr[acum] == -1)
Dr[acum] = Dist[itD].first - st;
++itD;
}
dr = p;
}
if(-p > st) {
while(itD != Dist.size() && Dist[itD].first <= dr - p) {
int acum = Dist[itD].second;
if(Dr[acum] == -1)
Dr[acum] = dr;
if(St[acum + 1] == -1)
St[acum + 1] = Dist[itD].first - dr;
++itD;
}
st = -p;
}
}
for(int i = 1; i <= n; ++i) {
if(St[i] == -1) St[i] = st;
if(Dr[i] == -1) Dr[i] = dr;
cout << St[i] + Dr[i] << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |