Submission #915483

#TimeUsernameProblemLanguageResultExecution timeMemory
915483ReLiceSnowball (JOI21_ho_t2)C++14
100 / 100
78 ms8600 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define vll vector<ll> #define bc back() #define arr array #define pll vector<pair<ll,ll>> using namespace std; template <class _T> bool chmin(_T &x, const _T &y){ bool f=0; if (x>y){x=y;f=1;} return f; } template <class _T> bool chmax(_T &x, const _T &y){ bool f=0; if (x<y){x=y;f=1;} return f; } //void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=2e18+7; const ll mod=1e9+7; const ll N=1e5+7; const ld eps=1e-9; void solve(){ ll i,j; ll n,m; cin>>n>>m; vll v(n); deque<pair<ll,ll>> v2; for(i=0;i<n;i++){ cin>>v[i]; if(i>0)v2.pb({v[i]-v[i-1],i-1}); } vll ans(n,0); sort(all(v2)); ll l=0,r=0,x=0; for(i=0;i<m;i++){ ll b; cin>>b; x+=b; l=min(l,x); r=max(r,x); while(v2.sz && v2[0].fr<=r+abs(l)){ if(x<0){ ans[v2[0].sc]+=r; ans[v2[0].sc+1]+=v2[0].fr-r; }else{ ans[v2[0].sc+1]+=abs(l); ans[v2[0].sc]+=v2[0].fr-abs(l); } v2.pof; } } for(i=0;i<v2.sz;i++){ ans[v2[i].sc]+=r; ans[v2[i].sc+1]+=abs(l); } ans[0]+=abs(l); ans[n-1]+=r; for(i=0;i<n;i++) cout<<ans[i]<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* */

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:75:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(i=0;i<v2.sz;i++){
      |              ^
Main.cpp:46:10: warning: unused variable 'j' [-Wunused-variable]
   46 |     ll i,j;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...