Submission #61024

# Submission time Handle Problem Language Result Execution time Memory
61024 2018-07-25T06:06:58 Z nvmdava Rice Hub (IOI11_ricehub) C++17
100 / 100
51 ms 2192 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

vector<long long> v;
bool price(int X[], int l,int r, long long B){
	
	int i;
	long long p = 0;
	int m = (r + l) / 2;
	
	p = X[m] * (m - l - r + m) - v[m] + v[l] + v[r + 1] - v[m + 1];
	
	if(p <= B){
		return 1;
	} else {
		return 0;
	}
	
}

int besthub(int n, int L, int X[], long long B)
{
	v.push_back(0);
	for(int i = 0; i < n; i ++){
		v.push_back(v.back() + X[i]);
	}
	int l = 0, r = 0, m,dif = -1,i;
	for(i = 0; i < n;i++){
		l = i; r = n ;
		while(l + 1 != r){
			m = (l+r) / 2;
			if(price(X,i,m,B)){
				l = m;
			} else {
				r = m;
			}
		}
		dif = max(dif , r - i);
	}
	return dif;
}

Compilation message

ricehub.cpp: In function 'bool price(int*, int, int, long long int)':
ricehub.cpp:8:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 3 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 568 KB Output is correct
2 Correct 3 ms 568 KB Output is correct
3 Correct 3 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 3 ms 576 KB Output is correct
7 Correct 3 ms 576 KB Output is correct
8 Correct 3 ms 576 KB Output is correct
9 Correct 4 ms 576 KB Output is correct
10 Correct 2 ms 576 KB Output is correct
11 Correct 3 ms 576 KB Output is correct
12 Correct 3 ms 576 KB Output is correct
13 Correct 3 ms 576 KB Output is correct
14 Correct 1 ms 576 KB Output is correct
15 Correct 3 ms 576 KB Output is correct
16 Correct 3 ms 576 KB Output is correct
17 Correct 3 ms 576 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 3 ms 636 KB Output is correct
20 Correct 3 ms 636 KB Output is correct
21 Correct 3 ms 636 KB Output is correct
22 Correct 3 ms 636 KB Output is correct
23 Correct 3 ms 636 KB Output is correct
24 Correct 3 ms 636 KB Output is correct
25 Correct 3 ms 636 KB Output is correct
26 Correct 3 ms 636 KB Output is correct
27 Correct 3 ms 636 KB Output is correct
28 Correct 3 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 636 KB Output is correct
2 Correct 3 ms 636 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 3 ms 636 KB Output is correct
5 Correct 3 ms 636 KB Output is correct
6 Correct 3 ms 636 KB Output is correct
7 Correct 4 ms 636 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 4 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Correct 4 ms 636 KB Output is correct
12 Correct 3 ms 636 KB Output is correct
13 Correct 3 ms 636 KB Output is correct
14 Correct 4 ms 636 KB Output is correct
15 Correct 3 ms 636 KB Output is correct
16 Correct 4 ms 636 KB Output is correct
17 Correct 4 ms 636 KB Output is correct
18 Correct 3 ms 636 KB Output is correct
19 Correct 4 ms 636 KB Output is correct
20 Correct 4 ms 636 KB Output is correct
21 Correct 5 ms 752 KB Output is correct
22 Correct 4 ms 752 KB Output is correct
23 Correct 4 ms 752 KB Output is correct
24 Correct 5 ms 752 KB Output is correct
25 Correct 6 ms 752 KB Output is correct
26 Correct 4 ms 752 KB Output is correct
27 Correct 4 ms 752 KB Output is correct
28 Correct 4 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1020 KB Output is correct
2 Correct 11 ms 1020 KB Output is correct
3 Correct 40 ms 2164 KB Output is correct
4 Correct 32 ms 2164 KB Output is correct
5 Correct 22 ms 2164 KB Output is correct
6 Correct 20 ms 2164 KB Output is correct
7 Correct 35 ms 2192 KB Output is correct
8 Correct 41 ms 2192 KB Output is correct
9 Correct 17 ms 2192 KB Output is correct
10 Correct 22 ms 2192 KB Output is correct
11 Correct 41 ms 2192 KB Output is correct
12 Correct 51 ms 2192 KB Output is correct
13 Correct 20 ms 2192 KB Output is correct
14 Correct 17 ms 2192 KB Output is correct
15 Correct 32 ms 2192 KB Output is correct
16 Correct 25 ms 2192 KB Output is correct
17 Correct 33 ms 2192 KB Output is correct
18 Correct 32 ms 2192 KB Output is correct
19 Correct 32 ms 2192 KB Output is correct
20 Correct 38 ms 2192 KB Output is correct