제출 #715554

#제출 시각아이디문제언어결과실행 시간메모리
715554vjudge1쌀 창고 (IOI11_ricehub)C++17
컴파일 에러
0 ms0 KiB
int besthub(int n,int l,int x[],int b){ int cost,mid,mx_cost,ans; vector<int> prefixSum(l,0); for(int i=1;i<=n;i++)prefixSum[i] = prefixSum[i-1]+x[i-1]; //for(int i=1;i<=n;i++)cout<<prefixSum[i]<<" "; cout<<endl; for(int st=1;st<=n;st++){ for(int en=st;en<=n;en++){ mid = (st+en)/2; cost = (mid-st)*x[mid]-(prefixSum[mid-1]-prefixSum[st-1]) + (prefixSum[en]-prefixSum[mid])-(en-mid)*x[mid]; if(cost <= b)ans = max(ans,en-st+1); //cout<<st<<" "<<en<<" "<<cost<<endl; } } return ans; }

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

ricehub.cpp: In function 'int besthub(int, int, int*, int)':
ricehub.cpp:3:5: error: 'vector' was not declared in this scope
    3 |     vector<int> prefixSum(l,0);
      |     ^~~~~~
ricehub.cpp:3:12: error: expected primary-expression before 'int'
    3 |     vector<int> prefixSum(l,0);
      |            ^~~
ricehub.cpp:5:26: error: 'prefixSum' was not declared in this scope
    5 |     for(int i=1;i<=n;i++)prefixSum[i] = prefixSum[i-1]+x[i-1];
      |                          ^~~~~~~~~
ricehub.cpp:10:37: error: 'prefixSum' was not declared in this scope
   10 |             cost = (mid-st)*x[mid]-(prefixSum[mid-1]-prefixSum[st-1]) + (prefixSum[en]-prefixSum[mid])-(en-mid)*x[mid];
      |                                     ^~~~~~~~~
ricehub.cpp:12:32: error: 'max' was not declared in this scope
   12 |             if(cost <= b)ans = max(ans,en-st+1);
      |                                ^~~
ricehub.cpp:2:18: warning: unused variable 'mx_cost' [-Wunused-variable]
    2 |     int cost,mid,mx_cost,ans;
      |                  ^~~~~~~