답안 #418397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
418397 2021-06-05T10:45:32 Z temurbek_khujaev 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;


int besthub(int R, int L, long long X[], long long B) {
    int ans = 0;
    vector<long long> pref(R, 0);
    for (int i = 0; i < R; i++) {
        pref[i] = i == 0 ? X[0] : (pref[i - 1] + X[i]);
    }
    for (int i = 0; i < R; i++) {
        int l = 1, r = R;
        while (l <= r) {
            int m = (l + r) >> 1;
            int left = i - m / 2 + 1;
            int right = i + (m + 1) / 2;
            bool good = false;
            if (left >= 0 && right < R) {
                long long s = 0;
                long long d1 = pref[right] - pref[i] - (right - i) * 1ll * X[i];
                long long d2 = 1ll * X[i] * (i - left + 1) - pref[i] + (left == 0 ? 0 : pref[left - 1]);
                good |= d1 + d2 <= B;
            }
            left--;
            right--;
            if (left >= 0 && right < R) {
                long long s = 0;
                long long d1 = pref[right] - pref[i] - (right - i) * 1ll * X[i];
                long long d2 = 1ll * X[i] * (i - left + 1) - pref[i] + (left == 0 ? 0 : pref[left - 1]);
                good |= d1 + d2 <= B;
            }
            left+=2;
            right+=2;
            if (left >= 0 && right < R) {
                long long s = 0;
                long long d1 = pref[right] - pref[i] - (right - i) * 1ll * X[i];
                long long d2 = 1ll * X[i] * (i - left + 1) - pref[i] + (left == 0 ? 0 : pref[left - 1]);
                good |= d1 + d2 <= B;
            }


            if (good) {
                l = m + 1;
                ans = max(ans, m);
            } else r = m - 1;
        }


    }


    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, long long int*, long long int)':
ricehub.cpp:21:27: warning: unused variable 's' [-Wunused-variable]
   21 |                 long long s = 0;
      |                           ^
ricehub.cpp:29:27: warning: unused variable 's' [-Wunused-variable]
   29 |                 long long s = 0;
      |                           ^
ricehub.cpp:37:27: warning: unused variable 's' [-Wunused-variable]
   37 |                 long long s = 0;
      |                           ^
/usr/bin/ld: /tmp/cc106btC.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