Submission #483629

# Submission time Handle Problem Language Result Execution time Memory
483629 2021-10-31T11:39:41 Z PoPularPlusPlus Rice Hub (IOI11_ricehub) C++17
0 / 100
3 ms 460 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}

int besthub(int n , int t , int arr[] , ll b){
	ll p[n];
	p[0] = arr[0];
	for(int i = 1; i < n; i++){
		p[i] = (arr[i] * 1LL) + p[i-1];
	}
	int ans = 1;
	for(int i = 0; i < n; i++){
		int l = 0 , r = i;
		//ll cur = 0;
		while(l <= r){
			ll mid = (l + r)/2;
			ll sum = (i - 1 >= 0 ? p[i-1] : 0) ,  res = 0;
			if(i - mid > 0)sum -= p[i - (mid + 1)];
			sum = (mid * 1LL * arr[i]) - (mid * 1LL * sum);
			for(int j = 0; j < 2; j++){
				int rp = i + mid + j;
				if(rp < n && rp >= i){
					ll s = p[i + mid + j];
					s -= p[i];
					ll cnt = mid + j;
					ll s1 = sum + ((cnt * 1LL * s) - (cnt * 1LL * arr[i]));
					if(s1 <= b){
						res = max(res , (mid+1+mid+j));
					}
				}
			}
			if(res == 0){
				r = mid - 1;
			}
			else l = mid + 1;
			ans = max(ans , (int)res);
			//cur = max(cur, res);
		}
		//cout << cur << ' ';
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -