Submission #1027765

# Submission time Handle Problem Language Result Execution time Memory
1027765 2024-07-19T09:45:40 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
0 / 100
1000 ms 1372 KB
#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
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1372 KB Time limit exceeded
2 Halted 0 ms 0 KB -