Submission #145022

# Submission time Handle Problem Language Result Execution time Memory
145022 2019-08-18T12:46:33 Z mhy908 Rice Hub (IOI11_ricehub) C++14
0 / 100
5 ms 760 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){
                ans=max(ans, r-l+2);
                break;
            }
            if(r==l){
                ans=max(ans, r-l+1);
            }
            l++;
        }
    }
    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 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -