#include<bits/stdc++.h>
//#include "ricehub"
using namespace std;
#define ss second
#define ff first
#define endl '\n'
int besthub(int r, int l, int x[], long long B){
int ans=0;
map<int,int> mp;
for(int i=0; i<r; i++) mp[x[i]]++;
for(int i=0; i<r; i++){
int b=B;
int sum=mp[x[i]];
int lt=i-1,rt=i+1;
while(lt>=0||rt<r){
if(lt>=0&&(abs(x[i]-x[lt])<=abs(x[i]-x[rt])||rt==r)){
if(abs(x[i]-x[lt])>b) break;
sum++;
b-=abs(x[i]-x[lt--]);
}else{
if(abs(x[i]-x[rt])>b) break;
sum++;
b-=abs(x[i]-x[rt++]);
}
}
ans=max(ans,sum);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1368 KB |
Output is correct |
2 |
Correct |
8 ms |
1596 KB |
Output is correct |
3 |
Incorrect |
170 ms |
8416 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |