Submission #1038122

#TimeUsernameProblemLanguageResultExecution timeMemory
1038122ArthuroWichRice Hub (IOI11_ricehub)C++17
68 / 100
1025 ms1004 KiB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int n, int l, int x[], long long B) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int co = 0; 
        long long s = B;
        vector<int> a;
        for (int j = 0; j < n; j++) {
            a.push_back(abs(x[i]-x[j]));
        }
        sort(a.rbegin(), a.rend());
        while(!a.empty() && a.back() <= s) {
            co++;
            s -= a.back();
            a.pop_back();
        }
        ans = max(ans, co);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...