답안 #145014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145014 2019-08-18T12:27:25 Z mhy908 쌀 창고 (IOI11_ricehub) C++14
0 / 100
1000 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=0, 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;
        ^
ricehub.cpp:17:69: warning: array subscript is below array bounds [-Warray-bounds]
             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];
                                                              ~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -