elephants
#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
int n,l;
int arr[50100],st[50100];
void init(int N, int L, int X[]){
n = N;
l=L;
for(int i=0;i<N;i++)
st[i]=arr[i]=X[i];
}
int update(int i, int y) {
if(!l)return n;
int ans=0,lst=-1e9;
int p=lower_bound(st,st+n,arr[i])-st;
while(p<n-1&&y>st[p+1])st[p]=st[p+1],p++;
while(p&&y<st[p-1])st[p]=st[p-1],p--;
st[p]=arr[i]=y;
for(int b=0;b<n;b++)
if(lst+l<st[b])
lst=st[b],ans++;
return ans;
}
Compilation message
elephants.cpp:2:5: error: 'elephants' does not name a type
2 | elephants
| ^~~~~~~~~