#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
class pont{
public:
int index;
int ut, el;
};
vector<pont> p;
const bool operator<(const pont& p1, const pont& p2){
return p1.index < p2.index;
}
long long L;
long long mennyi(long long e, long long i, long long u){
//cout << p[e].ut-p[i].ut << ' ' << (i-e)*(L-p[i].index) << ' ' <<
// p[u].el-p[i].el << ' ' << (u-i)*p[i].index << '\n';
return p[e].ut-p[i].ut-(i-e)*(L-p[i].index)
+p[u].el-p[i].el-(u-i)*p[i].index;
}
int besthub(int n, int l, int x[], long long b)
{
L=l;
int er=0;
p.resize(n);
for(int i=0;i<n;i++){
p[i].index=x[i];
}
sort(p.begin(),p.end());
p[0].el=p[0].index;
for(int i=1;i<n;i++){
p[i].el=p[i-1].el+p[i].index;
}
p[n-1].ut=l-p[n-1].index;
for(int i=n-2;i>=0;i--){
p[i].ut=p[i+1].ut+l-p[i].index;
}
for(int i=0;i<n;i++){
int aa=i, bb = n-1, k;
while(aa!=bb){
k=(aa+bb) /2+1;
if(mennyi(i, (i+k)/2,k)<=b){
aa=k;
} else {
bb=k-1;
}
}
//cout << i << ":" << aa << '\n';
er=max(er,aa-i+1);
}
//cout << p[2].ut << ' ' << p[3].ut << ' ' << p[4].ut << '\n' <<
// p[2].el << ' ' << p[3].el << ' ' << p[4].el << '\n'
// << mennyi(2,3,4) << '\n';
return er;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
364 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
380 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
388 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
504 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
860 KB |
Output is correct |
2 |
Correct |
7 ms |
760 KB |
Output is correct |
3 |
Correct |
29 ms |
2936 KB |
Output is correct |
4 |
Incorrect |
29 ms |
2936 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |