# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
112348 |
2019-05-19T02:21:45 Z |
socho |
Rice Hub (IOI11_ricehub) |
C++14 |
|
1000 ms |
2112 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int budget_handler;
int ricefield_count;
int len;
int arr[100001];
int summed_range(int left, int right) {
//
int median = arr[(left+right)/2];
int sm = 0;
for (int i=left; i<=right; i++) {
sm += abs(arr[i] - median);
}
// cout << "from " << left << " to " << right << " gives: " << sm << endl;
return sm;
}
int furthest_valid(int leftlock) {
int low = leftlock;
int high = ricefield_count;
int mid;
while (low + 1 < high) {
mid = (low + high) / 2;
if (summed_range(leftlock, mid) <= budget_handler) {
low = mid;
}
else {
high = mid;
}
}
if (high != ricefield_count) {
if (summed_range(leftlock, high) <= budget_handler) {
return high;
}
}
return low;
}
int besthub(int R, int L, int X[], long long B) {
budget_handler = B;
len = L;
ricefield_count = R;
for (int i=0; i<R; i++) {
arr[i] = X[i];
}
int mx = 0;
for (int i=0; i<R; i++) {
int besthere = furthest_valid(i);
// cout << i << " : " << besthere << endl;
mx = max(mx, besthere-i+1);
}
return mx;
}
# |
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 |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
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 |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 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 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
256 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
316 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 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 |
6 ms |
360 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
6 ms |
256 KB |
Output is correct |
20 |
Correct |
7 ms |
384 KB |
Output is correct |
21 |
Correct |
23 ms |
512 KB |
Output is correct |
22 |
Correct |
23 ms |
384 KB |
Output is correct |
23 |
Correct |
125 ms |
384 KB |
Output is correct |
24 |
Correct |
125 ms |
472 KB |
Output is correct |
25 |
Correct |
126 ms |
484 KB |
Output is correct |
26 |
Correct |
125 ms |
472 KB |
Output is correct |
27 |
Correct |
98 ms |
384 KB |
Output is correct |
28 |
Correct |
101 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
204 ms |
724 KB |
Output is correct |
2 |
Correct |
193 ms |
652 KB |
Output is correct |
3 |
Execution timed out |
1026 ms |
2112 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |