답안 #674726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674726 2022-12-26T01:31:57 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline ll read() {
    ll X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,l; ll c;
int a[N]; ll sum[N];

inline int check(int mid) {
    for (re int i=1,j=i+mid-1;j<=n;++i,++j) {
        ll now; int m=(i+j)>>1;
        if (mid&1) now=(sum[j]-sum[m])-(sum[m-1]-sum[i-1]);
        else now=(sum[j]-sum[m])-(sum[m]-sum[i-1]);
        if (now<=c) return 1;
    }
    return 0;
}

int main() {
    n=read(),l=read(),c=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    for (re int i=1;i<=n;++i) sum[i]=sum[i-1]+a[i];
    int L=1,R=n;
    while (L<R) {
        int mid=(L+R+1)>>1;
        if (check(mid)) L=mid;
        else R=mid-1;
    }
    printf("%d\n",L);
    return 0;
}

Compilation message

ricehub.cpp: In function 'int check(int)':
ricehub.cpp:24:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |     for (re int i=1,j=i+mid-1;j<=n;++i,++j) {
      |                 ^
ricehub.cpp:24:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |     for (re int i=1,j=i+mid-1;j<=n;++i,++j) {
      |                     ^
ricehub.cpp: In function 'int main()':
ricehub.cpp:35:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |     for (re int i=1;i<=n;++i) a[i]=read();
      |                 ^
ricehub.cpp:36:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |     for (re int i=1;i<=n;++i) sum[i]=sum[i-1]+a[i];
      |                 ^
/usr/bin/ld: /tmp/ccxA2i3t.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc7FZ3Xt.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccxA2i3t.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