#include "ricehub.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
using namespace std;
int besthub(int n, int l, vector<int> x, long long tmp_b)
{
multiset<int> tmp;
for (int i = 0; i < n; i++) tmp.insert(x[i]);
int mx = 0;
for (int& i : x)
{
int ans = 0;
multiset<int> ms = tmp;
long long b = tmp_b;
while (b)
{
auto it1 = ms.lower_bound(i);
int num1 = -1, num2 = -1;
if (it1 != ms.end()) num1 = *it1;
if (it1 != ms.begin()) it1--, num2 = *it1;
if (num1 == -1 && num2 == -1) continue;
if (num1 == -1)
{
if (i - num2 <= b) b -= i - num2, ans++, ms.erase(ms.find(num2));
else break;
}
else if (num2 == -1)
{
if (num1 - i <= b) b -= num1 - i, ans++, ms.erase(ms.find(num1));
else break;
}
else
{
if (min(num1 - i, i - num2) <= b)
{
if (num1 - i <= i - num2) b -= num1 - i, ans++, ms.erase(ms.find(num1));
else b -= i - num2, ans++, ms.erase(ms.find(num2));
}
else break;
}
}
mx = max(mx, ans);
}
return mx;
}
Compilation message
/usr/bin/ld: /tmp/ccghJEp3.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status