이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
int n;
int l;
pair<int,int> x[150005];
int pos[150005];
void init(int N, int L, int X[])
{
n = N;
l = L;
for(int i=0; i<n; i++) {
x[i] = make_pair(X[i], i);
}
sort(x, x+n);
for(int i=0; i<n; i++) {
pos[x[i].second] = i;
}
}
int update(int i, int y)
{
int ptr = pos[i];
x[ptr].first = y;
while(ptr > 0 && x[ptr] < x[ptr-1]) {
pos[x[ptr].second] = ptr-1;
pos[x[ptr-1].second] = ptr;
swap(x[ptr], x[ptr-1]);
--ptr;
}
while(ptr < n-1 && x[ptr] > x[ptr+1]) {
pos[x[ptr].second] = ptr+1;
pos[x[ptr+1].second] = ptr;
swap(x[ptr], x[ptr+1]);
++ptr;
}
int past = -1e9;
int ans = 0;
for(int i=0; i<n; i++) {
if(i==0 || past+l < x[i].first) {
ans++;
past = x[i].first;
}
}
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... |