Submission #1000219

#TimeUsernameProblemLanguageResultExecution timeMemory
1000219vicvicSnowball (JOI21_ho_t2)C++11
0 / 100
1 ms344 KiB
#include <iostream> #include <climits> using namespace std; const int nmax=2e5; long long int n, nrq, mx[nmax+5], mn[nmax+5], poz[nmax+5], rez[nmax+5]; int main() { cin >> n >> nrq; for (int i=1;i<=n;i++) { cin >> poz[i]; } long long int dep=0; for (int i=1;i<=nrq;i++) { long long int val; cin >> val; dep+=val; mn[i]=min (mn[i-1], dep); mx[i]=max (mx[i-1], dep); } rez[1]+=abs (mn[nrq]); rez[n]+=mx[nrq]; for (int i=2;i<=n;i++) { long long int st=1, dr=nrq, ret=0; while (st<=dr) { int mij = (st+dr) >> 1; if (poz[i]-poz[i-1]>mx[mij]-mn[mij]) { ret=mij; st=mij+1; } else dr=mij-1; } rez[i-1]+=mx[ret]; if (ret+1<=n && mx[ret+1]>mx[ret]) { rez[i-1]+=poz[i]-poz[i-1]-(mx[ret]-mn[ret]); } else if (ret+1<=n) { rez[i]+=poz[i]-poz[i-1]-(mx[ret]-mn[ret]); } rez[i]+=abs (mn[ret]); } for (int i=1;i<=n;i++) { cout << rez[i] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...