Submission #145016

# Submission time Handle Problem Language Result Execution time Memory
145016 2019-08-18T12:28:12 Z mhy908 Rice Hub (IOI11_ricehub) C++14
0 / 100
1000 ms 632 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long LL;
LL sum[100010];
int arr[100010];
int ans;
int besthub(int n, int m, int x[], LL b)
{
    int l=1, r;
    LL p=0;
    for(int i=0; i<n; i++)arr[i+1]=x[i];
    for(int i=1; i<=n; i++)sum[i]=sum[i-1]+(LL)arr[i];
    for(r=1; r<=n; r++){
        while(l<=r){
            int mid=(l+r)/2;
            LL temp=(LL)(mid-l+1)*(LL)arr[mid]-(LL)(sum[mid]-sum[l-1])+(LL)(sum[r]-sum[mid-1])-(LL)(r-mid+1)*(LL)arr[mid];
            if(temp>b)break;
            ans=max(ans, r-l+1);
        }
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, LL)':
ricehub.cpp:11:8: warning: unused variable 'p' [-Wunused-variable]
     LL p=0;
        ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 632 KB Time limit exceeded
2 Halted 0 ms 0 KB -