# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
409895 | Dan4Life | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KiB |
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 "grader.c"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int besthub(int n, int m, int a[], ll k)
{
ll ans = 0;
for(int i = 0; i < n; i++){
multiset<int> S; S.clear();
for(int j = 0; j < n; j++)
S.insert(abs(a[i]-a[j]));
ll K = k, cnt = 0;
while(!S.empty() and K>=(*S.begin()))
cnt++, K-=(*S.begin()), S.erase(S.begin());
if(ans<cnt)ans=cnt;
}
return ans;
}
int main() {
ll n, m, a[100], k; cin >> n >> m >> k;
for(int i = 0; i < n; i++) cin >> a[i];
cout << besthub(n,m,a,k);
}