#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define loop_rev(i, a, b) for(int i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pb push_back
using ll = long long;
vector<pair<int, int>> segs;
vector<int> x, y;
int n, d;
void brute_segs() {
segs.clear();
y = x;
sort(all(y));
int i = 0;
while(i < n) {
segs.pb({ y[i], y[i] + d });
while(i < n && y[i] <= segs.back().second) {
++i;
}
}
}
void init(int N, int L, int X[]) {
n = N, d = L;
x.resize(n);
loop(i, 0, n-1) {
x[i] = X[i];
}
brute_segs();
}
int update(int i, int new_x) {
x[i] = new_x;
brute_segs();
return sz(segs);
}
# | 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... |