Submission #97382

# Submission time Handle Problem Language Result Execution time Memory
97382 2019-02-15T16:47:15 Z Shafin666 Rice Hub (IOI11_ricehub) C++14
0 / 100
27 ms 3056 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<ll, ll>
#define to second
#define cost first
typedef long long ll;
typedef long double ld;
using namespace std;

ll besthub(int r, int l, int x[], ll b) {
	ll answer = 0;
	ll inf = 1e9+7, maxlen = -1;

	//sort(x, x+r);

		ll c = x[r/2];
		vector<ll> v;

		for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c));

		
		ll substart = 0, subend = 0;
		ll sum = 0;

		for(ll i = 0; i < r; i++) {
			sum += v[i];
			subend++;

			while(sum > b) {
				sum -= v[substart++];
			}
			maxlen = max(maxlen, subend-substart);
		}

		if(r<3) return maxlen;


	    c = x[(r+1)/2];
		v.clear();


		for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c));

		
		 substart = 0, subend = 0;
		 sum = 0;

		for(ll i = 0; i < r; i++) {
			sum += v[i];
			subend++;

			while(sum > b) {
				sum -= v[substart++];
			}
			maxlen = max(maxlen, subend-substart);
		}
	return maxlen;
}
/*
int main()
{	
	int x[1] = {1};
	cout << besthub(1, 20, x, 6) << endl;

    return 0;
}*/

Compilation message

ricehub.cpp: In function 'll besthub(int, int, int*, ll)':
ricehub.cpp:12:5: warning: unused variable 'answer' [-Wunused-variable]
  ll answer = 0;
     ^~~~~~
ricehub.cpp:13:5: warning: unused variable 'inf' [-Wunused-variable]
  ll inf = 1e9+7, maxlen = -1;
     ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 368 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Incorrect 2 ms 384 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Incorrect 3 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 6 ms 768 KB Output is correct
3 Correct 27 ms 3056 KB Output is correct
4 Correct 23 ms 2936 KB Output is correct
5 Correct 17 ms 1532 KB Output is correct
6 Correct 14 ms 1532 KB Output is correct
7 Correct 23 ms 2640 KB Output is correct
8 Correct 20 ms 2672 KB Output is correct
9 Correct 13 ms 1532 KB Output is correct
10 Correct 9 ms 1396 KB Output is correct
11 Correct 25 ms 3012 KB Output is correct
12 Correct 22 ms 2928 KB Output is correct
13 Incorrect 10 ms 1532 KB Output isn't correct
14 Halted 0 ms 0 KB -