Submission #499276

# Submission time Handle Problem Language Result Execution time Memory
499276 2021-12-27T18:08:31 Z dsyz Rice Hub (IOI11_ricehub) C++17
0 / 100
2 ms 440 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
using ll = long long;
#define MAXN (1000005)

int besthub(int R, int L, int X[], long long B){
	ll l = 0;
	ll r = 0;
	ll sum = 0;
	ll cur = 0;
	ll budget = 0;
	for(ll i = 1;i < R;i++){
		budget += abs(X[i] - X[0]);
		if(budget > B){
			break;
		}
		cur++;
		R++;
	}
	sum = max(sum,cur); 
	for(ll i = 1;i < R;i++){
		budget += abs(i - l) * abs(X[i] - X[i - 1]);
		budget -= abs(r - i + 1) * abs(X[i] - X[i - 1]);
		while(budget > B && l < i){
			budget -= abs(X[i] - X[l]);
			l++;
		}
		while(r < R - 1 && budget + X[r + 1] <= B){
			r++;
			budget += X[r];
			cur++;
		}
		while(l < i && r < R - 1){ 
			if(X[l] >= X[r + 1]){
				budget -= abs(X[i] - X[l]);
				budget += abs(X[r + 1] - X[i]); 
				l++;
				r++;
			}
		}
		while(r < R - 1 && budget + X[r + 1] <= B){
			r++;
			budget += X[r];
			cur++;
		}
		if(budget <= B){
			sum = max(sum,cur);
		}
	}
	return sum;
}
# 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 0 ms 204 KB Output isn't correct
2 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 2 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -