제출 #1217111

#제출 시각아이디문제언어결과실행 시간메모리
1217111nataliaaRice Hub (IOI11_ricehub)C++20
컴파일 에러
0 ms0 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { long long ans = 0; int l = 0, r = R; long long pre[n+1]={}; for(int i = 0; i< n; i++) pre[i+1]=pre[i]+x[i]; while(l<=r) { int m = (l+r)/2; bool t = 0; for(int i = 0; i < R ; i++) { if(i+m<=R) { int cnt = 0; int k = (m+i-1)/2; cnt+=(k - i)*X[k] - (pre[k] - pre[i]) + (pre[i+m] - pre[k +1]) - (i+m - k)*pre[k] if(cnt<=B) { t=1; break; } } else break; } if(t) l = m+1; else r= m-1; } return r; }

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

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:8:23: error: 'n' was not declared in this scope
    8 |         long long pre[n+1]={};
      |                       ^
ricehub.cpp:9:35: error: 'pre' was not declared in this scope
    9 |         for(int i = 0; i< n; i++) pre[i+1]=pre[i]+x[i];
      |                                   ^~~
ricehub.cpp:9:51: error: 'x' was not declared in this scope
    9 |         for(int i = 0; i< n; i++) pre[i+1]=pre[i]+x[i];
      |                                                   ^
ricehub.cpp:17:42: error: 'pre' was not declared in this scope
   17 |                     cnt+=(k - i)*X[k] - (pre[k] - pre[i]) + (pre[i+m] - pre[k +1]) - (i+m - k)*pre[k]
      |                                          ^~~