# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
79068 |
2018-10-11T02:53:21 Z |
Plurm |
Rice Hub (IOI11_ricehub) |
C++11 |
|
7 ms |
852 KB |
#include "ricehub.h"
#include <deque>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int lo = 0;
int hi = R;
int mid;
deque<int> dq;
deque<long long> qs;
long long QS[R];
QS[0] = X[0];
for(int i = 1; i < R; i++){
QS[i] = QS[i-1] + (long long)X[i];
}
while(lo < hi){
mid = (lo + hi + 1)/2;
dq.clear();
qs.clear();
for(int i = 0; i < mid; i++){
dq.push_back(X[i]);
qs.push_back(QS[i]);
}
long long s = qs[mid-1] - qs[mid/2] - (long long)(mid-mid/2-1)*dq[mid/2] +
(long long)(mid/2)*dq[mid/2] - qs[mid/2-1];
for(int i = mid; i < R; i++){
dq.pop_front();
qs.pop_front();
dq.push_back(X[i]);
qs.push_back(QS[i]);
s = min(s,qs[mid-1] - qs[mid/2] - (long long)(mid-mid/2-1)*dq[mid/2] +
(long long)(mid/2)*dq[mid/2] - qs[mid/2-1]);
}
if(s <= B){
lo = mid;
}else{
hi = mid-1;
}
}
return lo;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |