Submission #584654

# Submission time Handle Problem Language Result Execution time Memory
584654 2022-06-27T18:32:10 Z Blagojce Rice Hub (IOI11_ricehub) C++11
0 / 100
2 ms 340 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;


int besthub(int R, int L, int X[], long long B)
{
	int temp_budget = 0;
	int len = 1;
	int ans = 0;
	int l = 0, r = 0;
	for(int i = 0; i < R; i ++){
			if(r < i){
				r = i;
				l = i;
				len = 1;
			}
			if(i - l > r - i){
				temp_budget -= X[i] - X[l];
				--len;
				++l;
			}
			bool change = true;
			while(change){
				change = false;
				if(i - l < r - i){
					if(l > 0 && temp_budget + X[i] - X[l-1] <= B){
						temp_budget += X[i] - X[l-1];
						++len;
						--l;
						change = true;
					}
				}
				else{
					if(r + 1 < R && temp_budget + X[r+1] - X[i] <= B){
						temp_budget += X[r+1] - X[i];
						++len;
						++r;
						change = true;
					}
				}
			}
		
			
			ans = max(ans, len);
	}
	return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 2 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -