# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004679 | hacizadal | Rice Hub (IOI11_ricehub) | C++17 | 25 ms | 3028 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 "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
int besthub(int n, int l, int a[], long long b)
{
// 0 1 2 3 4 5
ll x = 0;
if (n%2==0){
x = a[n/2] + a[n/2-1];
x /= 2;
}
else {
x = a[n/2];
}
vector<ll>v;
for (ll i = 0; i<n; i++){
v.push_back(abs(x-a[i]));
}
sort(v.begin(), v.end());
ll sum = 0, cnt = 0;
for (ll j = 0; j<v.size(); j++){
sum += v[j];
cnt++;
if (sum > b){
cnt--;
break;
}
}
return cnt;
}
Compilation message (stderr)
# | 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... |