Submission #335884

# Submission time Handle Problem Language Result Execution time Memory
335884 2020-12-14T07:57:29 Z sumit_kk10 Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 748 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
 
long long int besthub(int n, int l, int a[], long long int b){
	long long int pre_sum[n] = {0}, suf_sum[n] = {0}, ans = 1;
	pre_sum[0] = a[0];
	suf_sum[n - 1] = a[n - 1];
	for(int i = 1; i < n; ++i)
		pre_sum[i] = pre_sum[i - 1] + a[i];
	for(int i = n - 2; i >= 0; --i)
		suf_sum[i] = suf_sum[i + 1] + a[i];
	for(int left = 0; left < n; ++left){
		int low = left, high = n - 1;
		while(low <= high){
			int right = (low + high) / 2;
			long long int middle = (left + right) / 2;
			long long int val = pre_sum[right] - pre_sum[middle] + suf_sum[left] - suf_sum[middle];
			val -= (a[middle] * (right - left));
			// cout << left << ' ' << right << ' ' << middle << ' ' << val << '\n';
			if(val <= b){
				ans = max(ans, (long long int) right - left + 1);
				low  = right + 1;
			}
			else
				high = right - 1;
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -