#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
int n;
int l;
pair<int,int> tmp[150005];
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++) {
tmp[i] = make_pair(X[i], i);
}
sort(tmp, tmp+n);
for(int i=0; i<n; i++) {
x[i] = tmp[i].first;
pos[tmp[i].second] = i;
}
}
int update(int i, int y)
{
int ptr = pos[i];
x[ptr] = y;
while(ptr > 0 && x[ptr] < x[ptr-1]) {
swap(pos[x[ptr]], pos[x[ptr-1]]);
swap(x[ptr], x[ptr-1]);
--ptr;
}
while(ptr < n-1 && x[ptr] > x[ptr+1]) {
swap(pos[x[ptr]], pos[x[ptr+1]]);
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]) {
ans++;
past = x[i];
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |