이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "elephants.h"
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
const int MAX = 1e5 + 15;
int n, l, pos[MAX];
vector<int> x;
void init(int n_, int l_, int x_[]){
n = n_, l = l_;
x.resize(n);
for(int i = 0; i < n; i++)
x[i] = x_[i], pos[i] = x[i];
}
int update(int i, int y){
vector<int> a, b, c;
int id = 0;
while(x[id] < pos[i])
a.emplace_back(x[id++]);
for(int j = id + 1; j < n; j++)
b.emplace_back(x[j]);
c.emplace_back(y);
if(sz(a) > sz(b)) swap(a, b);
vector<int> aux(sz(a) + sz(b)), ret(sz(a) + sz(b) + sz(c));
merge(all(a), all(b), aux.begin());
merge(all(aux), all(c), ret.begin());
swap(ret, x);
int ans = 0, r = -1;
for(int j = 0; j < n; j++)
if(x[j] > r) ans++, r = x[j] + l;
pos[i] = y;
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... |