#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 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 |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |