Submission #764333

# Submission time Handle Problem Language Result Execution time Memory
764333 2023-06-23T10:45:19 Z boris_mihov Dancing Elephants (IOI11_elephants) C++17
0 / 100
0 ms 340 KB
#include "elephants.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <random>
#include <vector>
#include <set>

typedef long long llong;
const int MAXN = 150000 + 10;
const int INF  = 2e9;

int n, len;
int a[MAXN];
void init(int N, int L, int X[])
{
    n = N;
    len = L;
    for (int i = 0 ; i < n ; ++i)
    {
        a[i + 1] = X[i];
    }
}

int update(int idx, int y)
{
    idx++;
    a[idx] = y;
    while (idx > 1 && a[idx - 1] > a[idx])
    {
        std::swap(a[idx - 1], a[idx]);
        idx--;
    }

    while (idx < n && a[idx + 1] < a[idx])
    {
        std::swap(a[idx], a[idx + 1]);
        idx++;
    }

    int coveredTo = -1, ans = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        if (coveredTo < a[i])
        {
            ans++;
            coveredTo = a[i] + len;
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -