Submission #453666

# Submission time Handle Problem Language Result Execution time Memory
453666 2021-08-04T13:59:09 Z ponytail Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include "bits/stdc++.h"
#define int long long
using namespace std;
int besthub(int R, int L, int X[], int B){
    int N = R;
    int x[N+1], ps[N+1], ans=0, lb=1, rb=N;
    for(int i=1;i<=N;i++)x[i] = X[i-1];
    ps[0]=0;
    for(int i=1;i<=N;i++) ps[i]=ps[i-1]+x[i];
    while(lb<rb){
        int mid=(lb+rb+1)/2;
        bool ok=0;
        for(int i=1;i<=N-mid+1;i++){
            int idx=(2*i+mid-1)/2;
            int cost=x[idx]*(idx-i+1)-ps[idx]+ps[i-1]+ps[i+mid-1]-ps[idx-1]-x[idx]*(i+mid-idx);
            if(cost<=B) ok=1;
        }
        if(ok) lb=mid;
        else rb=mid-1;
    }
    return lb;
}

Compilation message

ricehub.cpp: In function 'long long int besthub(long long int, long long int, long long int*, long long int)':
ricehub.cpp:8:26: warning: unused variable 'ans' [-Wunused-variable]
    8 |     int x[N+1], ps[N+1], ans=0, lb=1, rb=N;
      |                          ^~~
/usr/bin/ld: /tmp/ccgxMaG9.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