# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404767 | ScarletS | Snowball (JOI21_ho_t2) | C++17 | 154 ms | 16964 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>
#define int long long
#define sz(x) (int)(x).size()
using namespace std;
int ans[200000];
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n,m,x=0,y=0,z=0,k;
cin>>n>>m;
int a[n];
vector<array<int,2>> v(n-1),w(n-1);
for (int i=0;i<n;++i)
cin>>a[i];
for (int i=0;i+1<n;++i)
v[i]=w[i]={a[i+1]-a[i],i};
sort(v.rbegin(), v.rend());
sort(w.rbegin(), w.rend());
while (m--)
{
cin>>k;
z+=k;
if (k<0)
{
while (!v.empty()&&v.back()[0]<=y-z)
{
ans[v.back()[1]+1]+=max(v.back()[0]-y,-x);
//cout<<v.back()[1]+1<<" "<<v.back()[0]-y<<"\n";
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |