제출 #130307

#제출 시각아이디문제언어결과실행 시간메모리
130307UserIsUndefined쌀 창고 (IOI11_ricehub)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int R, L, X[100005]; ll money, pre[100005]; bool ok(int mid){ for(int i=0; i<=R-mid; i++){ int pos = mid / 2 + i; int A = mid / 2; int B = mid - A; ll S1 = pre[i + A - 1]; if(i > 0) S1 -= pre[i - 1]; ll S2 = pre[pos + B - 1]; if(pos > 0) S2 -= pre[pos - 1]; ll cost = A * X[pos] - S1 + S2 - B * X[pos]; if(cost <= money) return 1; } return 0; } int main() { scanf("%d %d %lld", &R, &L, &money); for(int i=0; i<R; i++) scanf("%d", X + i); pre[0] = X[0]; for(int i=1; i<R; i++) pre[i] = pre[i - 1] + X[i]; int st = 1, en = R; while(st < en){ int mid = (st + en + 1) / 2; if(ok(mid)) st = mid; else en = mid - 1; } printf("%d", st); return 0; }

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

ricehub.cpp: In function 'int main()':
ricehub.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %lld", &R, &L, &money);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", X + i);
     ~~~~~^~~~~~~~~~~~~
/tmp/ccblq7ZZ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccp7l2th.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/ccblq7ZZ.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