답안 #78802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
78802 2018-10-09T03:23:28 Z CaQtiml 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long LL;

const int MAXR = 100100;

int r, l;
LL b, x[MAXR], sum[MAXR];
int ans;

void read() {
    scanf("%d %d %lld", &r, &l, &b);
    for(int i = 1; i <= r; i ++) {
        scanf("%lld", &x[i]);
        sum[i] = sum[i - 1] + x[i];
    }
}

inline LL getSum(int le, int ri) {
    return sum[ri] - sum[le - 1];
}

inline LL calc(int le, int ri) {
    int mid = (le + ri) >> 1;
    LL br1 = mid - le + 1;
    LL br2 = ri - mid + 1;
    return (br1 * x[mid] - getSum(le, mid)) + (getSum(mid, ri) - br2 * x[mid]);
}

void solve() {
    int le = 1;
    ans = 1;
    for(int ri = 2; ri <= r; ri ++) {
        while(calc(le, ri) > b)
            le ++;
        ans = max(ans, ri - le + 1);
    }

    cout << ans << endl;
}

int main()
{
    read();
    solve();

    return 0;
}

Compilation message

ricehub.cpp: In function 'void read()':
ricehub.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %lld", &r, &l, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &x[i]);
         ~~~~~^~~~~~~~~~~~~~~
/tmp/ccYE3n4t.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cccbDrxa.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/ccYE3n4t.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status