제출 #36353

#제출 시각아이디문제언어결과실행 시간메모리
36353funcsrDancing Elephants (IOI11_elephants)C++14
26 / 100
9000 ms18812 KiB
#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 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...