# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
904992 |
2024-01-12T12:34:19 Z |
Macker |
Rice Hub (IOI11_ricehub) |
C++14 |
|
11 ms |
3420 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
vector<ll> v;
ll b, n;
bool can(ll k){
ll med = v[k / 2];
ll dst = 0;
for (ll i = 0; i < k / 2; i++) {
dst += med - v[i];
}
for (ll i = k / 2; i < k; i++) {
dst += v[i] - med;
}
if(dst <= b) return true;
ll lmed = med;
for (ll i = k; i < n; i++) {
med = v[(i + i - k + 1) / 2];
dst -= med - v[i - k];
dst += v[i] - lmed;
if(dst <= b) return true;
lmed = med;
}
return false;
}
int besthub(int R, int L, int X[], long long B)
{
v.assign(X, X+R);
b = B;
n = R;
ll l = 0, r = R - 1, mid;
while(l < r){
mid = (l + r + 1) / 2;
if(can(mid)) l = mid;
else r = mid - 1;
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
3 ms |
516 KB |
Output is correct |
3 |
Incorrect |
11 ms |
3420 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |