제출 #411281

#제출 시각아이디문제언어결과실행 시간메모리
411281LouayFarah코끼리 (Dancing Elephants) (IOI11_elephants)C++14
26 / 100
9087 ms1808 KiB
#include "bits/stdc++.h"
#include "elephants.h"
using namespace std;

int n, l;
int *x;
vector<int> pos;
vector<int> ele;

void init(int N, int L, int X[])
{
    n = N;
    l = L;
    x = X;
    pos.resize(n);
    ele.resize(n);
    for(int i = 0; i<n; i++)
    {
        pos[i] = i;
        ele[i] = x[i];
    }

}

int solve()
{
    int len = x[0];
    len+=l;
    int res = 1;
    int j = 1;
    while(j<n)
    {
        while(j<n&&x[j]<=len)
            j++;
        res++;
        len = x[j]+l;
    }

    return res-1;
}

int update(int i, int y)
{
    int ind = lower_bound(x, x+n, ele[i]) - x;
    x[ind] = y;
    ele[i] = y;
    sort(x, x+n);
    int res = solve();
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...