제출 #269151

#제출 시각아이디문제언어결과실행 시간메모리
269151Plurm코끼리 (Dancing Elephants) (IOI11_elephants)C++11
50 / 100
9033 ms1784 KiB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;

int n, l;
int arr[150005];
int pos[150005];
void init(int N, int L, int X[])
{
	n = N;
	l = L;
	for(int i = 0; i < N; i++){
		arr[i] = X[i];
		pos[i] = X[i];
	}
}

int update(int i, int y)
{
	int idx = lower_bound(arr, arr+n, pos[i]) - arr;
	for(int j = idx; j < n; j++) arr[j] = arr[j+1];
	pos[i] = y;
	idx = lower_bound(arr, arr+n-1, pos[i]) - arr;
	for(int j = n-1; j > idx; j--) arr[j] = arr[j-1];
	arr[idx] = pos[i];
	int last = -1;
	int c = 0;
	for(int j = 0; j < n; j++){
		if(last < arr[j]){
			last = arr[j]+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...