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 "elephants.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
using namespace std;
int n;
long long l;
vector<long long> elephant_positions;
set<long long> sorted_elephant_set;
void init(int N, int L, int X[])
{
n = N;
l = L;
for (int i = 0; i < N; i++){
elephant_positions.push_back(X[i]);
sorted_elephant_set.insert(X[i]);
}
}
int update(int i, int y)
{
sorted_elephant_set.erase(elephant_positions[i]);
sorted_elephant_set.insert(y);
elephant_positions[i] = y;
long long current_start = -2 * l;
long long current_cameras = 0;
for (set<long long>::iterator it = sorted_elephant_set.begin(); it != sorted_elephant_set.end(); it++){
if (*(it) - current_start > l){
current_start = *(it);
current_cameras++;
}
}
return current_cameras;
}
# | 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... |