이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long> > > v;
pair<long long, long long> p[200005];
long long a[200005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, x, sum=0, mx0=0, mx1=0;
cin >> n >> m;
a[0]=-1e18, a[n+1]=1e18;
for (long long i=1; i<=n; i++)
cin >> a[i];
v.push_back({0, {0, 0}});
for (long long i=1; i<=m; i++)
{
cin >> x;
sum+=x;
mx0=max(mx0, sum);
mx1=max(mx1, -sum);
v.push_back({mx0+mx1, {mx0, mx1}});
}
for (long long i=0; i<=n; i++)
{
long long ind=lower_bound(v.begin(), v.end(), make_pair(a[i+1]-a[i]+1, make_pair(0LL, 0LL)))-v.begin();
if (ind==m+1)
p[i]=v[ind-1].second;
else if (v[ind-1].second.first==v[ind].second.first)
p[i]={v[ind].second.first, a[i+1]-a[i]-v[ind].second.first};
else
p[i]={a[i+1]-a[i]-v[ind].second.second, v[ind].second.second};
if (i)
cout << p[i-1].second+p[i].first << '\n';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |