답안 #996361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996361 2024-06-10T13:54:33 Z hasan2006 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
#define ll long long

const int N = 1e5 + 9 , mod = 1e9 + 7;
ll a[N] ;


int besthub(int R, int L, vector<int>X, ll B) {
    ll i , l , r , m , k , x , s , ans = 0;
    for(i = 1; i <= R; i++)
        a[i] = X[i - 1] + a[i - 1];
    for(i = 1; i <= R; i++){
        l = i , r = R;
        while(l != r){
            m = (l + r + 1) / 2;
            x = (m + i) / 2;
            s = (a[x] * (x - i) - (a[x - 1] - a[i - 1])) + (a[m] - a[x] - a[x] * (m - x));
            if(s <= B)  l = m;
            else  r =  m - 1;
        }
        ans = max(ans , r - i + 1);
    }
    return ans;
}
// Author : حسن

Compilation message

ricehub.cpp: In function 'int besthub(int, int, std::vector<int>, long long int)':
ricehub.cpp:11:24: warning: unused variable 'k' [-Wunused-variable]
   11 |     ll i , l , r , m , k , x , s , ans = 0;
      |                        ^
/usr/bin/ld: /tmp/ccj0HhKn.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