#include<bits/stdc++.h>
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++;
mp[x[lt]]--;
b-=abs(x[i]-x[lt]);
if(mp[x[lt]]==0) lt--;
}else{
if(abs(x[i]-x[rt])>b) break;
sum++;
mp[x[rt]]--;
b-=abs(x[i]-x[rt]);
if(mp[x[rt]]==0) rt++;
}
}
ans=max(ans,sum);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
1620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |