Submission #418237

# Submission time Handle Problem Language Result Execution time Memory
418237 2021-06-05T08:36:32 Z Maqsut_03 Rice Hub (IOI11_ricehub) C++14
0 / 100
5 ms 332 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;

int besthub(int R, int L, int X[], long long B)
{
	int ans = 0, m;
	for (int i=0; i<R; i++)
	{
		int sum = 0, b = B, j = i;
		int l = i - 1, r = i + 1;
		while (1)
		{
			if (r < R && l >= 0 && X[i] - X[l] <= X[r] - X[i]) m = X[i] - X[l], l--;
			else if (r < R) m = X[r] - X[i], r++;
			else break;
			if (m > b) break;
			else sum++, b -= m;
		}
		ans = max(ans, sum);
	}
    return ans;
} 

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:11:23: warning: unused variable 'j' [-Wunused-variable]
   11 |   int sum = 0, b = B, j = i;
      |                       ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -