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;
int l;
int *x;
int uni[70000];
int siz = 0;
void init(int N, int L, int X[])
{
n = N;
l=L;
x=X;
for(int i = 0;i<n;i++){
uni[siz]=x[i];
siz++;
}
sort(uni,uni+siz);
}
void rem(int ind){
for(int i = ind+1;i<siz;i++){
uni[i-1]=uni[i];
}
siz--;
}
void add(int ind , int val){
siz++;
for(int i = siz;i>ind;i--){
uni[i]=uni[i-1];
}
uni[ind]=val;
}
int update(int i, int y)
{
for(int e = 0;e<siz;e++){
if(uni[e]==x[i]){
rem(e);
break;
}
}
x[i]=y;
if(uni[siz-1]<x[i]){
add(siz,x[i]);
}
else{
for(int e = 0;e<siz;e++){
if(uni[e]>=x[i]){
add(e,x[i]);
break;
}
}
}
int ans = 1;
int las = uni[0];
for(int i = 0;i<siz;i++){
int curr = uni[i];
if(curr-las>l){
las=curr;
ans++;
}
}
return ans;
}
# | 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... |