#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int n, int L, int X[], long long B){
long long sum = 0;
int num = 0;
int last = 0;
vector<long long> PR(n);
int ans = 0,ps = 0;
for (int i = 0 ; i < n; i++) {
sum += X[i];
PR[i] = sum;
num++;
while (true) {
long long e = sum/num;
int pos = lower_bound(X, X + i, e) - X;
long long s = X[pos]*(pos - last + 1) - (PR[pos] - (last ? PR[last] : 0)) - (PR[i] - PR[pos]) -X[pos]*( i - pos);
if (s <= B)
if (ans < i - last + 1)
ans = i - last + 1, ps = X[pos];
if (pos < i) {
pos++;
s =X[pos]*(pos - last + 1) - (PR[pos] - (last ? PR[last] : 0)) - (PR[i] - PR[pos]) -X[pos]*( i - pos);
if (s <= B)
if (ans < i - last + 1)
ans = i - last + 1, ps = X[pos];
}
if (s > B) {
last++;
num--;
continue;
}
else {
if (ans < i - last + 1)
ans = max(i - last + 1,ans);
break;
}
}
}
return ps;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |