Submission #583026

#TimeUsernameProblemLanguageResultExecution timeMemory
583026Mystic03Rice Hub (IOI11_ricehub)C++17
0 / 100
3 ms468 KiB
#include "ricehub.h"
#include <iostream>

using namespace std;
int besthub(int R, int L, int X[], long long B)
{
	int n = R;
	int from = 0;
	int to = 0;

	long long cost = 0;
	int res = 1;
	while (true) {
		int currRange = to - from + 1;
		to++;
		if (to >= n) break;

		int newDist = X[to] - X[to - 1];
		cost += (long long)currRange * newDist;

		while (cost > B) {
			if (from > to)  exit(1);
			cost -= (long long)X[to] - X[from];
			from++;
		}

		res = max(res, to - from + 1);
	}
	
	return res;

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...