이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int besthub(int n, int l, int x[], long long b)
{
long long max_rez=-1, sol=1;
for(int i=0; i<n; i++)
{
multiset<int>s;
for(int j=0; j<n; j++)
{
s.insert(abs(x[j]-x[i]));
}
long long sum=0, rez=0;
for(auto it=s.begin(); it!=s.end(); it++)
{
sum+=(*it);
if(sum>b)
{
break;
}
rez++;
}
if(max_rez<rez)
{
rez=max_rez;
sol=x[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 |
|---|
| 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... |