Submission #705429

#TimeUsernameProblemLanguageResultExecution timeMemory
705429penguin133Rice Hub (IOI11_ricehub)C++17
68 / 100
1080 ms1712 KiB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int besthub(int R, int L, int X[], long long B)
{
  int ans = 0;
  for(int i = 0; i < R; i++){
	  int l = i - 1, r = i + 1, cnt = 1, cst = 0;
	  while(l >= 0 || r < R){
		  if(l < 0 || (r != R && X[i] - X[l] > X[r] - X[i])){
			  if(X[r] - X[i] + cst > B)break;
			  cst += X[r] - X[i];
			  r++;
		  }
		  else{
			  if(X[i] - X[l] + cst > B)break;
			  cst += X[i] - X[l];
			  l--;
		  }
		  cnt++;
	  }
	  ans = max(ans, cnt);
  }
  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...