This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Problem: P5 - Dancing Elephants
// Contest: DMOJ - IOI '11
// URL: https://dmoj.ca/problem/ioi11p5
// Memory Limit: 256 MB
// Time Limit: 4000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
int n, l;
int x[150000], o[150000];
// int idx[150000];
void init(int N, int L, int X[])
{
n = N, l = L;
for(int i = 0; i < N; i++)
{
x[i] = X[i];
o[i] = x[i];
}
return;
}
int update(int i, int y)
{
int p = lower_bound(x, x+n, o[i])-x;
x[p] = y;
o[i] = y;
while(p && x[p] < x[p-1])
{
swap(x[p], x[p-1]);
p--;
}
while(p+1 < n && x[p] > x[p+1])
{
swap(x[p], x[p+1]);
p++;
}
int beg = x[0];
int ans = 1;
for(int j = 0; j < n; j++)
{
if(x[j]-beg > l)
{
beg = x[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... |