Submission #410600

# Submission time Handle Problem Language Result Execution time Memory
410600 2021-05-23T06:55:23 Z 600Mihnea Dancing Elephants (IOI11_elephants) C++17
0 / 100
1 ms 332 KB
#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 time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct