Submission #1027629

# Submission time Handle Problem Language Result Execution time Memory
1027629 2024-07-19T08:06:21 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
int besthub(int n, int l, int x[], long long b)
{
    int a[l+1];
    memset(a, 0, sizeof(a));
    for(int i=0; i<n; i++)
        a[x[i]]=1;
    long long max_rez=-1, sol=0;
    for(int i=1; i<=l; i++)
    {
        int bb=b;
        int rezz=a[i];
        for(int j=i-1, k=i+1; j>0 || k<=l; k++, j--)
        {
            if(j>0 && a[j]==1 && bb-(i-j)>=0)
            {
                bb-=(i-j);
                rezz++;
            }
            else if(j>0 && bb-(i-j)<0)
                break;
            if(k<=l && a[k]==1 && bb-(k-i)>=0)
            {
                bb-=(k-i);
                rezz++;
            }
            else if(k<=l && bb-(k-i)<0)
                break;
        }
        if(max_rez<rezz)
        {
            max_rez=rezz;
            sol=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;
}

Compilation message

/usr/bin/ld: /tmp/ccVOd49J.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccSLBK0N.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status