Submission #404767

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4047672021-05-15 00:50:32ScarletSSnowball (JOI21_ho_t2)C++17
100 / 100
154 ms16964 KiB
#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";
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...