제출 #116618

#제출 시각아이디문제언어결과실행 시간메모리
116618dragonslayerit코끼리 (Dancing Elephants) (IOI11_elephants)C++14
50 / 100
9082 ms1784 KiB
#include "elephants.h" #include <vector> #include <algorithm> const int INF=1e9+7; int xs[100005]; int ys[100005]; int n; int l; void init(int N, int L, int X[]) { n=N; l=L; for(int i=0;i<N;i++){ xs[i]=ys[i]=X[i]; } } int update(int index, int new_val) { int low=0,high=n-1; while(true){ int mid=(low+high)/2; if(ys[mid]<xs[index]){ low=mid+1; }else if(ys[mid]>xs[index]){ high=mid-1; }else{ int i=mid; while(i>0&&ys[i-1]>new_val){ ys[i]=ys[i-1]; i--; } while(i+1<n&&ys[i+1]<new_val){ ys[i]=ys[i+1]; i++; } ys[i]=new_val; break; } } xs[index]=new_val; int far=-INF; int cnt=0; for(int i=0;i<n;i++){ if(ys[i]>far){ far=ys[i]+l; cnt++; } } return cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...