Submission #67563

# Submission time Handle Problem Language Result Execution time Memory
67563 2018-08-15T01:28:29 Z Hoget157 Rice Hub (IOI11_ricehub) C++14
0 / 100
10 ms 920 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n,m,x[100010],b,l[100010] = {},r[100010] = {};

bool C(ll mid,ll num){
	ll A = num / 2,B = num - num / 2 - 1;
	ll mi = 1e+18;
	if(mid + A <= n && mid - B >= 0) mi = l[mid + A] - l[mid + 1] - x[mid] * A + r[mid - B] - r[mid] - (m - x[mid]) * B;
	if(num % 2 && mid + B <= n && mid - A >= 0) mi = min(mi,l[mid + B] - l[mid + 1] - x[mid] * B + r[mid - A] - r[mid] - (m - x[mid]) * A);
	return mi <= b;
}

int besthub(int R, int L, int X[], long long B){
	n = R,m = L,b = B;
	for(ll i = 0;i < n;i++) x[i] = X[i];
	ll ma = 0;
	for(ll i = 0;i < n;i++) l[i + 1] = l[i] + x[i];
	for(ll i = n - 1;i >= 0;i--) r[i] = r[i + 1] + L - x[i];
	for(ll i = 0;i < n;i++){
		ll low = 1,up = n + 1;
		while(up - low > 1){
			ll mid = (up + low) / 2;
			if(C(i,mid)) low = mid;
			else up = mid;
		}
		ma = max(ma,low);
	}
	return ma;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 920 KB Output isn't correct
2 Halted 0 ms 0 KB -