This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define designed ios_base::sync_with_stdio(0);
#define by cin.tie(0);
#define AndreasK cout.tie(0);
#define ii pair <int,int>
#define vi vector <int>
#define iii pair <int,ii>
#define vii vector <ii>
#define vc vector <char>
#define vb vector <bool>
int besthub(int R, int L, int X[], long long B)
{
int x=X[R/2],y=X[R/2];
if (R%2==0)
y=X[R/2-1];
vi a;
vi b;
for (int c=0;c<R;c++)
a.push_back(abs(x-X[c]));
for (int c=0;c<R;c++)
b.push_back(abs(y-X[c]));
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int Ba=B,Bb=B;
int p1=0,p2=0;
for (int c=0;c<R;c++){
if (a[c]<=Ba){
Ba-=a[c];
p1++;
}
if (b[c]<=Bb){
Bb-=b[c];
p2++;
}
}
return max(p1,p2);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |