답안 #335940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335940 2020-12-14T11:04:13 Z aryan12 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.cpp"
using namespace std;

long long besthub(long long r, long long l, long long x[], long long b) {
    long long ans = 1;
    for(long long i = 2; i <= r; i++) {
        long long left = 1, right = i, best = r;
        long long mid;
        while(left <= right) {
            mid = (left + right) / 2;
            long long FieldSituated = (mid + i) / 2, cost = 0;
            //cout << "left = " << left << ", right = " << right << ", mid = " << mid << ", FieldSituated = " << FieldSituated << ", cost = ";
            for(long long j = mid; j <= i; j++) {
                cost += (abs(x[j] - x[FieldSituated]));
            }
            //cout << cost << endl;
            if(cost <= b) {
                right = mid - 1;
                best = mid;
            }
            else {
                left = mid + 1;
            }
        }
        ans = max(ans, i - best + 1);
    }
    return ans;
}

/*int main() {
    cout << "Input the number of rice fields" << endl;
    long long r;
    cin >> r;
    cout << "Input the maximum coordinate" << endl;
    long long l;
    cin >> l;
    cout << "Input r numbers, denoting the rice fields" << endl;
    long long x[r + 1];
    for(long long i = 1; i <= r; i++) {
        cin >> x[i];
    }
    cout << "Input the budget" << endl;
    long long b;
    cin >> b;
    cout << besthub(r, l, x, b) << endl;
}
*/

Compilation message

ricehub.cpp:2:10: fatal error: ricehub.cpp: No such file or directory
    2 | #include "ricehub.cpp"
      |          ^~~~~~~~~~~~~
compilation terminated.