Submission #261624

# Submission time Handle Problem Language Result Execution time Memory
261624 2020-08-11T23:00:44 Z c4ts0up Rice Hub (IOI11_ricehub) C++17
17 / 100
691 ms 3872 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n;
vector <ll> arr;

int besthub(int R, int L, int X[], ll B) {
	//cerr << "Entrando a besthub..." << endl;
	
	n = (ll)R;
	
	// creamos el arreglo
	for (ll i=0; i<n; i++) arr.push_back((ll)X[i]);
	
	ll lb = 0, ub = 0, suma = 0LL, prev, maxi = 1LL;
	
	//cerr << "Entrando al loop..." << endl;
	for (ll i=0; i<n; i++) {
		cerr << "I = " << i << endl;
		// 1. Actualizamos la suma
		if (!i) {} // no toca si i == 0
		else {
			//cerr << "La suma paso de " << suma << " a ";
			
			suma -= ((ub-(i-1))*(abs(prev-arr[i])));
			suma += ((i-lb)*(abs(prev-arr[i])));
			
			//cerr << suma << endl;
		}
		
		// 2. Recogemos lb
		while (suma > B) {
			suma -= abs(arr[lb]-arr[i]);
			lb++;
		}
		
		// 3. Expandimos ub
		while (ub+1 < n) {
			if (suma + abs(arr[ub+1]-arr[i]) <= B) suma += abs(arr[ub+1]-arr[i]), ub++;
			else break;
		}
		
		//cerr << "Nuevos valores, lb = " << lb << ", ub = " << ub << endl;
		
		// 4. Contar
		maxi = max(maxi, ub-lb+1);
		
		prev = arr[i];
	}
	
	return maxi;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Incorrect 1 ms 384 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
13 Correct 7 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Incorrect 4 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 132 ms 1140 KB Output is correct
2 Correct 137 ms 1012 KB Output is correct
3 Correct 665 ms 3872 KB Output is correct
4 Correct 691 ms 3816 KB Output is correct
5 Correct 329 ms 2032 KB Output is correct
6 Correct 328 ms 1936 KB Output is correct
7 Correct 672 ms 3512 KB Output is correct
8 Correct 663 ms 3408 KB Output is correct
9 Correct 331 ms 1856 KB Output is correct
10 Correct 329 ms 1840 KB Output is correct
11 Correct 674 ms 3820 KB Output is correct
12 Correct 672 ms 3736 KB Output is correct
13 Incorrect 335 ms 2032 KB Output isn't correct
14 Halted 0 ms 0 KB -