제출 #101104

#제출 시각아이디문제언어결과실행 시간메모리
101104ansol4328쌀 창고 (IOI11_ricehub)C++11
컴파일 에러
0 ms0 KiB
#include<stdio.h> typedef long long ll; bool pos(int del, long long *m, long long B, int n) { int cnt=n-del; int hcnt=cnt/2; long long d=0; for(int i=0 ; i<cnt/2 ; i++) d+=m[cnt-i+1]-m[i]; if(d<=B) return true; for(int i=0 ; i<n-cnt ; i++) { int didx=i, aidx=i+cnt; d-=m[didx+hcnt]-m[didx]; d+=m[aidx]-m[aidx-hcnt]; if(d<=B) return true; } return false; } int besthub(int R, long long L, long long *X, long long B) { int st=0, fn=R, mid, res; while(st<=fn) { mid=(st+fn)>>1; if(pos(mid,X,B,R)) fn=mid-1, res=mid; else st=mid+1; } return R-res; }

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

ricehub.cpp: In function 'int besthub(int, long long int, long long int*, long long int)':
ricehub.cpp:31:14: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return R-res;
              ^~~
/tmp/ccbQ4oj1.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