Submission #137001

#TimeUsernameProblemLanguageResultExecution timeMemory
137001amiratouRice Hub (IOI11_ricehub)C++14
0 / 100
1004 ms612 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
using namespace std;

int besthub(int R, int L, int X[], long long B)
{
	int ans=0;
	for (int i = 0; i < R; ++i)
	{
		int idx=i,comp=1;
		ll rem=B;
		priority_queue<pair<ii,int>,vector<pair<ii,int>>,greater<pair<ii,int> > > q;
		if(idx-1>=0)q.push({{X[idx]-X[idx-1],idx-1},0});
		if(idx+1<R)q.push({{X[idx+1]-X[idx],idx+1},1});
		while(!q.empty()){
			pair<ii,int> front =q.top();
			q.pop();
			if(front.fi.fi>rem)break;
			rem-=front.fi.fi,comp++;
			if(front.se&&front.fi.se+1<R)
				q.push({{X[front.fi.se+1]-X[front.fi.se],front.fi.se+1},1});
			if(!front.se&&front.fi.se-1>=0)
				q.push({{X[front.fi.se]-X[front.fi.se-1],front.fi.se-1},0});
		}
		//cerr<<i<<" "<<comp<<"\n";
		ans=max(ans,comp);
	}
	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...