Submission #719570

# Submission time Handle Problem Language Result Execution time Memory
719570 2023-04-06T09:54:20 Z mseebacher Rice Hub (IOI11_ricehub) C++17
0 / 100
3 ms 468 KB
#include <bits/stdc++.h> 

using namespace std;

int besthub(int R, int L, int x[], long long B)
{
	vector<long long> pref(R+1,0);
	for(int i = 0;i<R;i++){
		pref[i+1] = pref[i]+x[i];
	}
	int ans = 0;
	int l = 0;
	int r = R-1;
	int len;
	while(l+1<r){
		len = (l+r) >> 1;
		bool b = 0;
		for(int i = 0;i<R-len;i++){
			int j = i+len;
			int mid = (i+j) >> 1;
			long long cost = (long long)(mid-i)*x[mid]*1LL-(pref[mid]-pref[i]) ; // Seg unten
			cost += (long long)(pref[j+1]-pref[mid+1])-(j-mid)*x[mid]*1LL; // seg oben
				
			if(cost <= B) {
				ans = max(ans,j-i+1);
				b = 1;
			}
		}
		if(b) l = len+1;
		else r = len-1;
	}
  return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Incorrect 3 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -