Submission #919943

#TimeUsernameProblemLanguageResultExecution timeMemory
919943LalicDancing Elephants (IOI11_elephants)C++17
26 / 100
9049 ms10748 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());

vector<pii> arr;
int l;

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

int update(int i, int y)
{
	vector<pii> proc;
	bool b=0;
	for(int j=0;j<(int)arr.size();j++){
		if(arr[j].se==i) continue;
		if(!b && arr[j].fi>=y){
			proc.pb({y, i});
			b=1;
		}
		proc.pb(arr[j]);
	}
	if(!b) proc.pb({y, i});
	arr=proc;
	
	int curr=-l-1, ans=0;
	for(auto u : arr){
		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...