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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50000;
int pos[N];
int x[N];
int n;
set<int> val;
int l;
void init(int N, int L, int X[])
{
n = N;
l = L;
for (int i = 0; i < n; i++) x[i] = X[i];
for (int i = 0; i < n; i++)
{
pos[i] = x[i];
}
}
int update(int ind, int y)
{
int nx[N];
bool added = false;
int curr = 0;
for (int i = 0; i < n; i++)
{
if (x[i] == pos[ind]) continue;
if (x[i] > y && !added)
{
nx[curr] = y;
added = true;
curr++;
}
nx[curr] = x[i];
curr++;
}
if (!added) nx[curr] = y;
swap(x, nx);
int last = -1;
int res = 0;
pos[ind] = y;
for(int i = 0; i < n; i++)
{
if (x[i] > last)
{
last = x[i] + l;
res++;
}
}
return res;
}
# | 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... |