Submission #919944

#TimeUsernameProblemLanguageResultExecution timeMemory
919944LalicDancing Elephants (IOI11_elephants)C++17
26 / 100
9068 ms12904 KiB
#include <bits/stdc++.h>
#include "elephants.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 15e4+10;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

pii arr[MAXN], aux[MAXN];
int l, n;

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

int update(int i, int y)
{
	bool b=0;
	int cnt=0;
	for(int j=0;j<n;j++){
		if(arr[j].se==i) continue;
		if(!b && arr[j].fi>=y){
			aux[cnt++]=mp(y, i);
			b=1;
		}
		aux[cnt++]=arr[j];
	}
	if(!b) aux[cnt++]=mp(y, i);
	for(int j=0;j<n;j++) arr[j]=aux[j];
	
	int curr=-l-1, ans=0;
	for(int j=0;j<n;j++){
		pii u=arr[j];
		if(u.fi<=curr+l) continue;
		curr=u.fi;
		ans++;
	}
	
	return ans;
}
#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...