제출 #1000009

#제출 시각아이디문제언어결과실행 시간메모리
1000009vicvicSnowball (JOI21_ho_t2)C++11
0 / 100
0 ms348 KiB
#include <iostream> #include <climits> using namespace std; const int nmax=2e5; int n, nrq, mx[nmax+5], mn[nmax+5], poz[nmax+5], mn_dep=INT_MIN, mx_dep=INT_MIN, rez[nmax+5]; int main() { cin >> n >> nrq; for (int i=1;i<=n;i++) { cin >> poz[i]; } int dep=0; for (int i=1;i<=nrq;i++) { 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++) { 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] << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...