이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
struct st{
ll a,b,c;
friend bool operator < (st a, st b)
{
return a.a<b.a;
}
};
main()
{
ll n,z;
cin>>n>>z;
ll cad[n];
ll v[2][n];
for(int i=0; i<n; i++)
{
cin>>cad[i];
v[0][i]=0;
v[1][i]=0;
}
priority_queue<st> q;
for(int i=0; i<n-1; i++)
{
q.push({-(cad[i+1]-cad[i]),i,i+1});
}
ll i=0;
ll d=0;
ll ia=0;
ll da=0;
while(z--)
{
ll t;
cin>>t;
ia+=t;
da+=t;
ll ac=-min(i,ia)+max(d,da);
while(!q.empty()&&ac>=-q.top().a)
{
st a=q.top();q.pop();
v[1][a.b]+=d;
v[0][a.c]+=i;
if(t<0)
v[0][a.c]-=(-a.a)-d+i;
else
v[1][a.b]+=(-a.a)-d+i;
}
i=min(i,ia);
d=max(d,da);
}
while(!q.empty())
{
st a=q.top();q.pop();
v[1][a.b]+=d;
v[0][a.c]+=i;
}
v[0][0]+=i;
v[1][n-1]+=d;
for(int i=0; i<n; i++)
{
cout<<v[1][i]-v[0][i]<<"\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |