답안 #552490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552490 2022-04-23T08:24:08 Z Sharky 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 100005
vector<int> ps(N, 0);
bool ok(int L, int R, int x, int& r, int& l, int& v[], long long& b) {
    int mid = (L + R) >> 1; // median
    // brute force
    int cost = v[mid] * (mid - L + 1) - (ps[mid] - ps[L - 1]);
    // cout << L << " " << R << " " << mid << " " << cost;
    cost += (ps[R] - ps[mid]) - v[mid] * (R - mid);
    // cout << " " << cost << "\n";
    return (cost <= b);

}
bool check(int x, int& r, int& l, int& v[], long long& b) {
    // x consecutive hubs
    for (int i = 1; i <= r - x + 1; i++) {
        if (ok(i, i + x - 1, x, r, l, v, b)) return true;
    }
    return false; 
}
int besthub(int r, int l, int v[], long long b) {
    int lo = 1, hi = r, ans; 
    while (lo <= hi) {
        int m = (lo + hi) >> 1;
        // cout << m << " " << check(m) << "\n";
        if (check(m, r, l, v, b)) lo = m + 1, ans = m;
        else hi = m - 1; 
    }
    return ans;
}

Compilation message

ricehub.cpp:7:51: error: declaration of 'v' as array of references
    7 | bool ok(int L, int R, int x, int& r, int& l, int& v[], long long& b) {
      |                                                   ^
ricehub.cpp:7:54: error: expected ')' before ',' token
    7 | bool ok(int L, int R, int x, int& r, int& l, int& v[], long long& b) {
      |        ~                                             ^
      |                                                      )
ricehub.cpp:7:56: error: expected unqualified-id before 'long'
    7 | bool ok(int L, int R, int x, int& r, int& l, int& v[], long long& b) {
      |                                                        ^~~~
ricehub.cpp:17:40: error: declaration of 'v' as array of references
   17 | bool check(int x, int& r, int& l, int& v[], long long& b) {
      |                                        ^
ricehub.cpp:17:43: error: expected ')' before ',' token
   17 | bool check(int x, int& r, int& l, int& v[], long long& b) {
      |           ~                               ^
      |                                           )
ricehub.cpp:17:45: error: expected unqualified-id before 'long'
   17 | bool check(int x, int& r, int& l, int& v[], long long& b) {
      |                                             ^~~~