답안 #36356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36356 2017-12-08T04:24:58 Z funcsr 코끼리 (Dancing Elephants) (IOI11_elephants) C++14
97 / 100
9000 ms 18812 KB
#pragma GCC optimize ("-O3")
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#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 lb(int len, int x) {
  int lo = -1, hi = len;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (B[mid] >= x) hi = mid;
    else lo = mid;
  }
  return hi;
}

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

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

  //
  int until = B[0]+L, c = 1;
  rep(i, N) if (B[i] > until) until = B[i]+L, c++;
  return c;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1039 ms 18812 KB Output is correct
2 Correct 1463 ms 18812 KB Output is correct
3 Correct 4143 ms 18812 KB Output is correct
4 Correct 4146 ms 18812 KB Output is correct
5 Correct 4176 ms 18812 KB Output is correct
6 Correct 3956 ms 18812 KB Output is correct
7 Correct 4099 ms 18812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2013 ms 18812 KB Output is correct
2 Correct 2736 ms 18812 KB Output is correct
3 Correct 5829 ms 18812 KB Output is correct
4 Correct 8069 ms 18812 KB Output is correct
5 Correct 8055 ms 18812 KB Output is correct
6 Correct 8026 ms 18812 KB Output is correct
7 Correct 8073 ms 18812 KB Output is correct
8 Correct 7876 ms 18812 KB Output is correct
9 Correct 8623 ms 18812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 9000 ms 18812 KB Execution timed out
2 Halted 0 ms 0 KB -