Submission #485364

# Submission time Handle Problem Language Result Execution time Memory
485364 2021-11-07T10:25:29 Z blue Dancing Elephants (IOI11_elephants) C++17
0 / 100
0 ms 204 KB
#include "elephants.h"
#include <vector>
#include <algorithm>
using namespace std;

const int maxN = 50'000;

int N;
int L;
int* X;
int* I;

void init(int N_, int L_, int X_[])
{
    N = N_;
    L = L_;
    X = new int[N];
    for(int i = 0; i < N; i++) X[i] = X_[i];

    I = new int[N];
    for(int i = 0; i < N; i++) I[i] = i;
}

int update(int i, int y)
{
    int oldX = X[i];
    X[i] = y;

    if(X[i] > oldX)
    {
        for(int i = 0; i+1 < N; i++)
        {
            if(X[I[i]] > X[I[i+1]])
                swap(I[i], I[i+1]);
        }
    }
    else
    {
        for(int i = N-2; i >= 0; i--)
        {
            if(X[I[i]] < X[I[i-1]])
                swap(I[i], I[i-1]);
        }
    }

    int ans = 0;
    int st = -1'000'000'001;

    for(int i = 0; i < N; i++)
    {
        if(X[I[i]] - st > L)
        {
            st = X[I[i]];
            ans++;
        }
    }

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