Submission #500325

#TimeUsernameProblemLanguageResultExecution timeMemory
500325aryan12코끼리 (Dancing Elephants) (IOI11_elephants)C++17
26 / 100
9086 ms2372 KiB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 5;
int n, len;
set<int> pos;
int cur_pos[MAXN];

void init(int N, int L, int X[]) {
    n = N;
    len = L;
    for(int i = 0; i < N; i++) {
        pos.insert(X[i]);
        cur_pos[i] = X[i];
    }
}

int update(int i, int y)
{
    pos.erase(cur_pos[i]);
    cur_pos[i] = y;
    pos.insert(cur_pos[i]);
    int ans = 0, x = *(pos.begin());
    while(true) {
        ans++;
        if(pos.lower_bound(x + len + 1) == pos.end()) {
            break;
        }
        x = *(pos.lower_bound(x + len + 1));
    }
    return ans;
}
#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...