답안 #741096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741096 2023-05-13T14:22:42 Z josanneo22 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,v,a[100005],sum[100005],ans=-1;
bool check(ll l,ll r)
{
    ll mid=(l+r)/2;
    return ((sum[r]-sum[mid])-(sum[mid-1]-sum[l-1])-a[mid]*((r-l)&1))<=v;//代码核心 
    //若r-l+1为偶数,即r-l为奇数时,少减了a[mid]。 
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&v);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    for(ll l=1,r=0;l<=n;l++)
    {
        while(r<n&&check(l,r+1))
            r++;
        ans=max(ans,r-l+1);
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

ricehub.cpp: In function 'int main()':
ricehub.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lld%lld%lld",&n,&m,&v);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccwAOvoP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQRGKGO.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccwAOvoP.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