Submission #36353

# Submission time Handle Problem Language Result Execution time Memory
36353 2017-12-08T03:47:47 Z funcsr Dancing Elephants (IOI11_elephants) C++14
26 / 100
9000 ms 18812 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cassert>
#include "elephants.h"
using namespace std;
#define INF 1145141919
#define rep(i, n) for (int i=0; i<(n); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define _1 first
#define _2 second
typedef pair<int, int> P;

int N, L;
int A[150000], B[150000];

void init(int n, int l, int X[]) {
  N = n, L = l;
  rep(i, N) A[i] = B[i] = X[i];
}

int update(int i, int y) {
  // remove A[i]
  int pos = lower_bound(B, B+N, A[i])-B;
  for (int x=pos; x<N-1; x++) B[x] = B[x+1];
  B[N-1] = 0;

  // insert y
  A[i] = y;
  pos = upper_bound(B, B+N-1, y)-B;
  for (int x=N-2; x>=pos; x--) B[x+1] = B[x];
  B[pos] = y;
  assert(is_sorted(B, B+N));

  //
  int until = B[0]+L, c = 1;
  rep(i, N) {
    if (B[i] > until) until = B[i]+L, c++;
  }
  return c;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18812 KB Output is correct
2 Correct 0 ms 18812 KB Output is correct
3 Correct 0 ms 18812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18812 KB Output is correct
2 Correct 0 ms 18812 KB Output is correct
3 Correct 0 ms 18812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3259 ms 18812 KB Output is correct
2 Correct 4643 ms 18812 KB Output is correct
3 Correct 6059 ms 18812 KB Output is correct
4 Correct 6386 ms 18812 KB Output is correct
5 Correct 6133 ms 18812 KB Output is correct
6 Execution timed out 9000 ms 18812 KB Execution timed out
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3446 ms 18812 KB Output is correct
2 Execution timed out 9000 ms 18812 KB Execution timed out
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9000 ms 18812 KB Execution timed out
2 Halted 0 ms 0 KB -