#include <bits/stdc++.h>
using namespace std;
int besthub(int n, int l, int x[], long long b)
{
int a[l+1];
memset(a, 0, sizeof(a));
for(int i=0; i<n; i++)
a[x[i]]=1;
long long max_rez=-1, sol=0;
for(int i=1; i<=l; i++)
{
int bb=b;
int rezz=a[i];
for(int j=i-1, k=i+1; j>0 || k<=l; k++, j--)
{
if(j>0 && a[j]==1 && bb-(i-j)>=0)
{
bb-=(i-j);
rezz++;
}
else if(j>0 && bb-(i-j)<0)
break;
if(k<=l && a[k]==1 && bb-(k-i)>=0)
{
bb-=(k-i);
rezz++;
}
else if(k<=l && bb-(k-i)<0)
break;
}
if(max_rez<rezz)
{
max_rez=rezz;
sol=i;
}
}
return sol;
}
/*int main()
{
int r, l;
long long b;
cin>>r>>l;
int x[r];
for(int i=0; i<r; i++)
cin>>x[i];
cin>>b;
cout<<besthub(r, l, x, b);
return 0;
}*/
# |
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 |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |