Submission #27153

# Submission time Handle Problem Language Result Execution time Memory
27153 2017-07-09T16:20:33 Z dwik Rice Hub (IOI11_ricehub) C++11
0 / 100
3 ms 6708 KB
#include <bits/stdc++.h>
#include "ricehub.h"
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: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:18:9: warning: unused variable 'id' [-Wunused-variable]
     int id = -1;
         ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 6708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 6708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 6708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6708 KB Output isn't correct
2 Halted 0 ms 0 KB -