Submission #551199

#TimeUsernameProblemLanguageResultExecution timeMemory
551199ymmRice Hub (IOI11_ricehub)C++17
100 / 100
15 ms704 KiB
///
///   There's a reason for your defeat, DIO. One simple reason...
///   You pissed me off.
///

#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define Kill(x) exit((cout << (x) << '\n', 0))
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
using namespace std;

#ifndef DARD
#include "ricehub.h"
#endif

int besthub(int r, int l, int x[], long long b)
{
	int ans = 0;
	ll cur = 0;
	for (int i=0, j=0; j < r;) {
		cur += x[j++];
		cur -= x[(j+i-1)/2];
//		cout << i << ' ' << j << ' ' << cur << '\n';
		while (cur > b) {
			cur += x[i++];
			cur -= x[(j+i-1)/2];
		}
//		cout << i << ' ' << j << ' ' << cur << '\n';
		ans = max(ans, j-i);
	}
	return ans;
}

#ifdef DARD
int main()
{
	int constexpr r = 5;
	int constexpr l = 20;
	ll constexpr b = 6;
	int x[] = {1, 2, 10, 12, 14};
	cout << besthub(r, l, x, b) << '\n';
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...