Submission #173889

# Submission time Handle Problem Language Result Execution time Memory
173889 2020-01-05T18:17:15 Z stefdasca Dancing Elephants (IOI11_elephants) C++14
10 / 100
2 ms 400 KB
#include<bits/stdc++.h>

using namespace std;

int n, lg;

int vals[150002], srt[150002], nw[150002];
void init(int N, int L, int X[])
{
    n = N;
    lg = L;
    for(int i = 1; i <= N; ++i)
        srt[i] = X[i-1], vals[i] = X[i-1];
    sort(srt + 1, srt + n + 1);
    srt[n+1] = 2100000000;
}

int binsearch(int val)
{
    int st = 1;
    int dr = n;
    int ans = 0;
    while(st <= dr)
    {
        int mid = (st + dr) / 2;
        if(srt[mid] <= val)
            ans = mid, st = mid + 1;
        else
            dr = mid - 1;
    }
    return ans;
}
int update(int i, int y)
{
    ++i;
    if(n == 2)
    {
        vals[i] = y;
        if(abs(vals[1] - vals[2]) > lg)
            return 2;
        return 1;
    }
  //  cout << vals[i] << " " << y << '\n';
    int pz = binsearch(vals[i]);
    int pma = pz;
    int pmb = pz+1;
    vals[i] = y;
    while(pma <= n)
    {
        if(y <= srt[pmb])
            srt[pma] = y, y = (1<<30), ++pma;
        else
            srt[pma] = srt[pmb], ++pmb, ++pma;
    }
    int ans = 0;
    int st = 0;
    for(int i = 1; i <= n;)
    {
        ++ans;
        st = srt[i];
        while(srt[i] - st <= lg)
            ++i;
    }
  //  for(int i = 1; i <= n; ++i)
  //      cout << srt[i] << " ";
  //  cout << '\n';
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -