Submission #27151

#TimeUsernameProblemLanguageResultExecution timeMemory
27151dwikRice Hub (IOI11_ricehub)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int sum[100009]; int cost(int a,int b){ int ret = 0; int mid = (a+b)/2; ret += sum[b]-sum[mid]-(sum[mid]-sum[mid-1])*(b-mid); ret += (sum[mid]-sum[mid-1])*(mid-a) - (sum[mid]-sum[a-1]); return ret; } int besthub(int n,int l,int x[],int b){ sum[1] = x[0]; for(int i=2;i<=n;i++){ sum[i] += sum[i-2]+x[i-1]; } int j = 1; int id = -1; int ans = 0; for(int i=1;i<=n;i++){ while(j<=n && cost(i,j)<=b){ j++; } if(cost(i,j-1)<=b){ if(j-i > ans){ ans = j-i; } } i++; j = max(j,i); } return ans; } /*int main(){ int n,l,x[100009],b; cin>>n>>l>>b; for(int i=0;i<n;i++)cin>>x[i]; cout<<besthub(n,l,x,b)<<endl; }*/ /* 5 20 6 1 2 10 12 14 */

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, int)':
ricehub.cpp:17:9: warning: unused variable 'id' [-Wunused-variable]
     int id = -1;
         ^
/tmp/ccy19wt7.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