# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
904925 |
2024-01-12T11:27:05 Z |
Macker |
Rice Hub (IOI11_ricehub) |
C++14 |
|
1000 ms |
604 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<int> v;
int b, n;
bool can(int k){
int med = v[k / 2];
int dst = 0;
for (int i = 0; i < k / 2; i++) {
dst += med - v[i];
}
for (int i = k / 2; i < k; i++) {
dst += v[i] - med;
}
if(dst <= b) return true;
int lmed = med;
for (int 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;
int l = 0, r = R, mid;
while(l < r){
mid = (l + r) / 2;
if(can(mid)) l = mid;
else r = mid - 1;
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |