#include "elephants.h"
#include "bits/stdc++.h"
using namespace std;
int n, l;
vector<int> a;
unordered_map<int, int> Mapa;
void init(int N, int L, int X[]){
  n = N;
  l = L;
  for(int i = 0; i < n; i++){
    Mapa[i] = i;
    a.push_back(X[i]);
  }
}
int update(int i, int y){
  a[Mapa[i]] = y;
  for(int j = Mapa[i]; j > 0; j--){
    if(a[j] >= a[j - 1]) break;
    else {
      swap(a[j], a[j - 1]);
      swap(Mapa[j], Mapa[j - 1]);
    }
  }
  for(int j = Mapa[i]; j < n - 1; j++){
    if(a[j] <= a[j + 1]) break;
    else {
      swap(a[j], a[j + 1]);
      swap(Mapa[j], Mapa[j + 1]);
    }
  }
  int r = 0, p = -2;
  for(auto E: a){
    if(p == -2){
      r++;
      p = E;
    } else if(E > p + l){
      r++;
      p = E;
    }
  }
  return r;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |