Submission #1027078

# Submission time Handle Problem Language Result Execution time Memory
1027078 2024-07-18T20:33:28 Z kkkkkkkk Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

vector<int> v;
int B;

bool proveri(int k) {
    for (int i=0;i<v.size()-k;i++) {
        int hub_poz=v[(i+i+k)/2];
        int zbir=0;
        bool ok=true;
        for (int j=i;j<i+k;j++) {
            zbir+=hub_poz-v[j];
            if (zbir>B) {
                ok=false;
                break;
            }
        }
        if (ok) return true;
    }
    return false;
}

int besthub(int R, int L, int a[], int b) {
    B=b;
    for (int i=0;i<R;i++)
        v.push_back(a[i]);
    int l=1, r=R+1;
    while (l+1<r) {
        int mid=(l+r)/2;
        if (proveri(mid)) l=mid;
        else r=mid;
    }
    return l;
}

Compilation message

ricehub.cpp: In function 'bool proveri(long long int)':
ricehub.cpp:11:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   11 |     for (int i=0;i<v.size()-k;i++) {
      |                  ~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccswHMDZ.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