# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
233424 | crossing0ver | Dancing Elephants (IOI11_elephants) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "elephants.h"
using namespace std;
int n,L,P[100000];
void init(int N, int L1, int X[])
{
n = N; L = L1;
for (int i = 0; i < n; i++) P[i+1] = X[i],s.insert(X[i]);
}
multiset<int> s;
int update(int i, int y)
{
i++;
s.erase(s.find(P[i]));
s.insert(y);
P[i] = y;
int last = INT_MIN,ans = 0;
for (auto it = s.begin(); it != s.end(); it++) {
if (*it > last + L)
ans++, last = *it;
}
return ans;
}