이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "elephants.h"
#include <set>
#include <algorithm>
using namespace std;
int n;
pair < int , int > all[150005];
int Next[150005];
int last[150005];
int cha[1500005];
int where[150005];
int l;
void init(int N, int l, int X[])
{
int i;
n = N;
::l=l;
for(i=0;i<N;i++) all[i+1]=make_pair(X[i],i);
sort(all+1,all+N+1);
for(i=1;i<=N;i++) where[i]=all[i].first;
for(i=1;i<=N;i++) cha[all[i].second]=i;
for(i=0;i<=N;i++) Next[i]=i+1;
for(i=0;i<=N;i++) last[i]=i-1;
where[N+1]=2e9;
}
int update(int i, int y)
{
int now=0,a,b,here,ll;
i=cha[i];
//printf("%d %d\n",i,y);
a=last[i];
b=Next[i];
Next[a]=b;
last[b]=a;
here=0;
while(1)
{
if(where[Next[here]]>y)
{
a=here;
b=Next[here];
Next[a]=i;
Next[i]=b;
last[b]=i;
last[i]=a;
break;
}
here=Next[here];
}
where[i]=y;
here=Next[0];
ll=where[here];
now=1;
while(here!=n+1)
{
//printf("%d\n",where[here]);
if(where[here]-ll>l)
{
now++;
ll=where[here];
}
here=Next[here];
}
return now;
}
# | 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... |