Submission #262423

# Submission time Handle Problem Language Result Execution time Memory
262423 2020-08-12T22:09:46 Z c4ts0up Rice Hub (IOI11_ricehub) C++17
0 / 100
25 ms 3572 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll n;
vector <ll> arr;
 
ll RO(ll budget, ll idx) {
	vector <int> pq;
	for (ll x : arr) pq.push_back(abs(x-arr[idx]));
	ll paks = 1, suma = 0, lb = idx-1, ub = idx+1;
	
	while (lb >= 0 || ub < n) {
		if (lb >= 0 && ub < n && pq[lb] <= pq[ub]) {
			if (suma + pq[lb] <= budget) suma += pq[lb], lb--, paks++;
			else break;
		}
		else if (lb >= 0 && ub < n && pq[lb] > pq[ub]) {
			if (suma + pq[ub] <= budget) suma += pq[ub], ub++, paks++;
			else break;
		}
		else if (lb >= 0) {
			if (suma + pq[lb] <= budget) suma += pq[lb], lb--, paks++;
			else break;
		}
		else if (ub < n) {
			if (suma + pq[ub] <= budget) suma += pq[ub], ub++, paks++;
			else break;
		}
		else {}
	}
	
	return paks;
}
 
int besthub(int R, int L, int X[], ll B) {
	for (ll i=0; i<R; i++) arr.push_back((ll)X[i]);
	
	n = R;
	
	return max(RO(B, n/2), RO(B, (n-1)/2));
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Incorrect 1 ms 256 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 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 512 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 Correct 1 ms 384 KB Output is correct
15 Incorrect 1 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 936 KB Output is correct
2 Correct 4 ms 936 KB Output is correct
3 Correct 20 ms 3572 KB Output is correct
4 Correct 22 ms 3552 KB Output is correct
5 Correct 8 ms 1784 KB Output is correct
6 Correct 10 ms 1784 KB Output is correct
7 Correct 25 ms 3188 KB Output is correct
8 Correct 16 ms 3188 KB Output is correct
9 Correct 7 ms 1712 KB Output is correct
10 Correct 8 ms 1712 KB Output is correct
11 Correct 20 ms 3552 KB Output is correct
12 Correct 21 ms 3560 KB Output is correct
13 Incorrect 9 ms 1784 KB Output isn't correct
14 Halted 0 ms 0 KB -