# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
350006 | idk321 | Dancing Elephants (IOI11_elephants) | C++11 | 9022 ms | 1644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50000;
int pos[N];
int x[N];
int n;
set<int> val;
int l;
void init(int N, int L, int X[])
{
n = N;
l = L;
for (int i = 0; i < n; i++) x[i] = X[i];
for (int i = 0; i < n; i++)
{
pos[i] = x[i];
}
}
int update(int ind, int y)
{
bool added = false;
int curr = -1;
for (int i = 0; i < n; i++)
{
if (x[i] == pos[ind])
{
curr = i;
x[i] = y;
pos[ind] = y;
break;
}
}
bool found = true;
while (found)
{
found = false;
//cout << curr << " " << x[curr] << endl;
if (curr != 0 && x[curr - 1] > x[curr])
{
swap(x[curr - 1], x[curr]);
curr--;
found = true;
}
if (curr != n - 1 && x[curr + 1] < x[curr])
{
swap(x[curr + 1], x[curr]);
curr++;
found = true;
}
}
int last = -1;
int res = 0;
for(int i = 0; i < n; i++)
{
if (x[i] > last)
{
last = x[i] + l;
res++;
}
}
return res;
}
Compilation message (stderr)
# | 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... |