Submission #27152

# Submission time Handle Problem Language Result Execution time Memory
27152 2017-07-09T16:19:08 Z dwik Rice Hub (IOI11_ricehub) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "
using namespace std;
long long sum[100009];
long long cost(int a,int b){
    long long 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[],long long 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

ricehub.cpp:2:10: warning: missing terminating " character
 #include "
          ^
ricehub.cpp:2:10: error: #include expects "FILENAME" or <FILENAME>
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:18:9: warning: unused variable 'id' [-Wunused-variable]
     int id = -1;
         ^