이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "elephants.h"
#include <vector>
#include <algorithm>
using namespace std;
const int maxN = 50'000;
int N;
int L;
int* X;
int* I;
void init(int N_, int L_, int X_[])
{
N = N_;
L = L_;
X = new int[N];
for(int i = 0; i < N; i++) X[i] = X_[i];
I = new int[N];
for(int i = 0; i < N; i++) I[i] = i;
}
int update(int i, int y)
{
int oldX = X[i];
X[i] = y;
if(X[i] > oldX)
{
for(int j = 0; j+1 < N; j++)
{
if(X[I[j]] > X[I[j+1]])
swap(I[j], I[j+1]);
}
}
else
{
for(int j = N-2; j >= 0; j--)
{
if(X[I[j]] > X[I[j+1]])
swap(I[j], I[j+1]);
}
}
int ans = 0;
int st = -1'000'000'001;
for(int j = 0; j < N; j++)
{
if(X[I[j]] - st > L)
{
st = X[I[j]];
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... |