Submission #830176

# Submission time Handle Problem Language Result Execution time Memory
830176 2023-08-18T22:35:00 Z OAleksa Rice Hub (IOI11_ricehub) C++14
0 / 100
2 ms 596 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define f first
#define s second
using namespace std; 

int besthub(int R, int L, int X[], long long B)
{
  	int n = R;
  	int a[n];
  	for(int i = 0;i < n;i++)
  		a[i] = X[i];
	int ans = 0;
	const int inf = 1e9 + 69;
	int l = 0, r = 0;
	long long t = 0;
	while(r < n && t + a[r] - a[0] <= B) {
		t += (a[r] - a[0]);
		++r;
		++ans;
	}
	for(int i = 1;i < n;i++) {
		if(i > r) {
			l = r = i;
			t = 0;
			while(r < n && t + a[r] - a[i] <= B) {
				t += (a[r] - a[i]);
				++r;
			}
		}
		else {
			t -= (r - i + 1) * (a[i] - a[i - 1]);
			t += (i - l) * (a[i] - a[i - 1]);
			while(t > B) 
				t -= (a[i] - a[l++]);
		}
		ans = max(ans, r - l + 1);
	}
	return ans;
}

// signed main()
// {
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	// int tt = 1;
	// //cin >> tt;
	// while(tt--) {
		 // int n, k;
		 // long long x;
		 // cin >> n >> k >> x;
		 // int a[n];
		 // for(int i = 0;i < n;i++)
		 	// cin >> a[i];
		// cout << besthub(n, k, a, x);
	// }
   // return 0;
// }

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:14:12: warning: unused variable 'inf' [-Wunused-variable]
   14 |  const int inf = 1e9 + 69;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -