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