Submission #771208

#TimeUsernameProblemLanguageResultExecution timeMemory
771208Trisanu_DasSnowball (JOI21_ho_t2)C++17
100 / 100
70 ms13920 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb emplace_back #define N 200010 int x[N],now,rmx,lmx,ans[N]; vector<pii> v; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,q,i,j,w; cin>>n>>q; x[0]=-1e18,x[n+1]=1e18; for(i=1;i<=n+1;i++){ if(i<=n) cin>>x[i]; v.pb(x[i]-x[i-1],i-1); } sort(all(v)); i=0; while(q--){ cin>>w; now+=w; rmx=max(now,rmx),lmx=min(now,lmx); while(rmx-lmx>=v[i].ff){ if(w>0) ans[v[i].ss]+=v[i].ff+lmx,ans[v[i].ss+1]-=lmx; else ans[v[i].ss]+=rmx,ans[v[i].ss+1]+=v[i].ff-rmx; i++; } } while(i<v.size()){ ans[v[i].ss]+=rmx,ans[v[i].ss+1]-=lmx; i++; } for(i=1;i<=n;i++) cout<<ans[i]<<'\n'; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:34:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  while(i<v.size()){
      |        ~^~~~~~~~~
Main.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
   15 |  int n,q,i,j,w;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...