제출 #410599

#제출 시각아이디문제언어결과실행 시간메모리
410599600Mihnea코끼리 (Dancing Elephants) (IOI11_elephants)C++17
26 / 100
9079 ms1960 KiB
#include <bits/stdc++.h>
#include "elephants.h"

using namespace std;

const int N = 150000 + 7;
int n, x[N], len, normal_ord[N];

int ind;

void init(int nn, int lenlen, int initial[]) {
  ind = 0;
  n = nn;
  len = lenlen;
  for (int i = 0; i < n; i++) {
    x[i] = normal_ord[i] = initial[i];
  }
  return;
}


void print(int v[]) {
  cout << " ----> ";
  for (int i = 0; i < n; i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

int update(int ii, int yy) {
  {
    int value = normal_ord[ii];
    normal_ord[ii] = yy;
    int l = 0, r = n - 1, sol = -1;
    while (l <= r) {
      int m = (l + r) / 2;
      if (x[m] == value) {
        sol = m;
        break;
      }
      if (x[m] < value) {
        l = m + 1;
      } else {
        r = m - 1;
      }
    }
    assert(sol != -1);
    ii = sol;
  }
  x[ii] = yy;
  sort(x, x + n);
  ind++;
  int cost = 0, l = 0;
  while (l < n) {
    cost++;
    int r = l;
    while (r + 1 < n && x[r + 1] - x[l] <= len) {
      r++;
    }
    l = r + 1;
  }

  return cost;
}
#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...