제출 #422240

#제출 시각아이디문제언어결과실행 시간메모리
422240ScarletS쌀 창고 (IOI11_ricehub)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int a[], long long B) { int l=0,r=R,m,x,y; bool ok; //cout<<L<<"!!\n"; long long cur; while (l<r) { ok=0; m=l+(r-l)/2+1; //cout<<m<<"!\n"; cur=0; x=0;y=m-1; for (int i=0;i<=y/2;++i) cur-=a[i]; for (int i=y/2+1;i<m;++i) cur+=a[i]; //cout<<cur<<" "; // cout<<1LL*a[(x+y)/2]*((m-1)/2+1)<<" "<<-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<<"\n"; //cout<<cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<<" "; if (cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<=B) ok=1; for (++x,++y;y<R;++x,++y) { //cout<<"\n"<<x<<" "<<y<<"\n"; cur+=a[x-1]; cur+=a[y]; cur-=a[(x+y)/2]*2; // cout<<"+ "<<a[x-1]<<"\n"; // cout<<"+ "<<a[y]<<"\n"; // cout<<"- 2*"<<a[(x+y)/2]<<"\n"; if (cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<=B) ok=1; //cout<<cur<<" "; //cout<<cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<<" "; } //cout<<"\n"; if (ok) l=m; else r=m-1; } return l; } int main() { int r,l,b; cin>>r>>l>>b; int x[r]; for (int i=0;i<r;++i) cin>>x[i]; cout<<besthub(r,l,x,b); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccBuG8Zg.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJswqWe.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status