# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
29493 |
2017-07-19T13:49:06 Z |
inqr |
Rice Hub (IOI11_ricehub) |
C++14 |
|
39 ms |
6316 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
using namespace std;
vector < int > presum;
int fienum,ans=0;
long long b;
long long sum(int l,int r){
if(l==0)return presum[r];
else return presum[r]-presum[l-1];
}
long long comp(int l,int r,int X[]){
int m=(l+r)/2;
int lc=m-l,rc=r-m;
return lc*X[m]-sum(l,m-1)+sum(m+1,r)-rc*X[m];
}
void solve(int s,int X[]){
int l=s,r=fienum-1;
while(l<=r){
int m=(l+r)/2;
//printf("s=%d l=%d r=%d m=%d comp=%d %d\n",s,l,r,m,comp(s,m,X).st,comp(s,m,X).nd);
if(comp(s,m,X)<=b){
l=m+1;
ans=max(ans,m-s+1);
}
else r=m-1;
}
}
int besthub(int R, int L, int X[], long long B)
{
fienum=R;b=B;
presum.resize(R);
presum[0]=X[0];
for(int i=1;i<R;i++)presum[i]=presum[i-1]+X[i];
for(int i=0;i<R;i++){
solve(i,X);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5924 KB |
Output is correct |
2 |
Correct |
0 ms |
5924 KB |
Output is correct |
3 |
Correct |
0 ms |
5924 KB |
Output is correct |
4 |
Correct |
0 ms |
5924 KB |
Output is correct |
5 |
Correct |
0 ms |
5924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5924 KB |
Output is correct |
2 |
Correct |
0 ms |
5924 KB |
Output is correct |
3 |
Correct |
0 ms |
5924 KB |
Output is correct |
4 |
Correct |
0 ms |
5924 KB |
Output is correct |
5 |
Correct |
0 ms |
5924 KB |
Output is correct |
6 |
Correct |
0 ms |
5924 KB |
Output is correct |
7 |
Correct |
0 ms |
5924 KB |
Output is correct |
8 |
Correct |
0 ms |
5924 KB |
Output is correct |
9 |
Correct |
0 ms |
5924 KB |
Output is correct |
10 |
Correct |
0 ms |
5924 KB |
Output is correct |
11 |
Correct |
0 ms |
5924 KB |
Output is correct |
12 |
Correct |
0 ms |
5924 KB |
Output is correct |
13 |
Correct |
0 ms |
5924 KB |
Output is correct |
14 |
Correct |
0 ms |
5924 KB |
Output is correct |
15 |
Correct |
0 ms |
5924 KB |
Output is correct |
16 |
Correct |
0 ms |
5924 KB |
Output is correct |
17 |
Correct |
0 ms |
5924 KB |
Output is correct |
18 |
Correct |
0 ms |
5924 KB |
Output is correct |
19 |
Correct |
0 ms |
5924 KB |
Output is correct |
20 |
Correct |
0 ms |
5924 KB |
Output is correct |
21 |
Correct |
0 ms |
5924 KB |
Output is correct |
22 |
Correct |
0 ms |
5924 KB |
Output is correct |
23 |
Correct |
0 ms |
5924 KB |
Output is correct |
24 |
Correct |
0 ms |
5924 KB |
Output is correct |
25 |
Correct |
0 ms |
5924 KB |
Output is correct |
26 |
Correct |
0 ms |
5924 KB |
Output is correct |
27 |
Correct |
0 ms |
5924 KB |
Output is correct |
28 |
Correct |
0 ms |
5924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5924 KB |
Output is correct |
2 |
Correct |
0 ms |
5924 KB |
Output is correct |
3 |
Correct |
0 ms |
5924 KB |
Output is correct |
4 |
Correct |
0 ms |
5924 KB |
Output is correct |
5 |
Correct |
0 ms |
5924 KB |
Output is correct |
6 |
Correct |
0 ms |
5924 KB |
Output is correct |
7 |
Correct |
0 ms |
5924 KB |
Output is correct |
8 |
Correct |
0 ms |
5924 KB |
Output is correct |
9 |
Correct |
0 ms |
5924 KB |
Output is correct |
10 |
Correct |
0 ms |
5924 KB |
Output is correct |
11 |
Correct |
0 ms |
5924 KB |
Output is correct |
12 |
Correct |
0 ms |
5924 KB |
Output is correct |
13 |
Correct |
0 ms |
5924 KB |
Output is correct |
14 |
Correct |
0 ms |
5924 KB |
Output is correct |
15 |
Correct |
0 ms |
5924 KB |
Output is correct |
16 |
Correct |
0 ms |
5924 KB |
Output is correct |
17 |
Correct |
0 ms |
5924 KB |
Output is correct |
18 |
Correct |
0 ms |
5924 KB |
Output is correct |
19 |
Correct |
0 ms |
5924 KB |
Output is correct |
20 |
Correct |
0 ms |
5924 KB |
Output is correct |
21 |
Correct |
0 ms |
5924 KB |
Output is correct |
22 |
Correct |
0 ms |
5924 KB |
Output is correct |
23 |
Correct |
0 ms |
5924 KB |
Output is correct |
24 |
Correct |
0 ms |
5924 KB |
Output is correct |
25 |
Correct |
0 ms |
5924 KB |
Output is correct |
26 |
Correct |
0 ms |
5924 KB |
Output is correct |
27 |
Correct |
0 ms |
5924 KB |
Output is correct |
28 |
Correct |
0 ms |
5924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6080 KB |
Output is correct |
2 |
Correct |
3 ms |
6080 KB |
Output is correct |
3 |
Correct |
39 ms |
6316 KB |
Output is correct |
4 |
Incorrect |
33 ms |
6316 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |