이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#include "elephants.h"
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;
const int MAXN = 70000;
int X[MAXN], n, L;
int A[MAXN]; // TODO: multiset
void init(int N, int L_, int X_[]) {
L = L_;
fill(A, A + MAXN, -1);
for (int i = 0; i < N; i++) {
X[i] = X_[i];
A[i] = X[i];
}
n = N;
}
int update(int i, int y) {
int ind = lower_bound(A, A + n, X[i]) - A;
int tx = X[i];
X[i] = y;
A[ind] = y;
if (tx < y) {
for (int i = 0; i < MAXN - 1; i++)
if (A[i] > A[i + 1] && A[i + 1] != -1)
swap(A[i], A[i + 1]);
} else {
for (int i = MAXN - 1; i > 0; i--) {
if (A[i] < A[i - 1] && A[i] != -1)
swap(A[i], A[i - 1]);
}
}
int ans = 0;
int v = -(L + 1);
for (int i = 0; i < MAXN; i++) {
if (A[i] > v + L) {
v = A[i];
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... |