답안 #1027629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027629 2024-07-19T08:06:21 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
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