답안 #145019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145019 2019-08-18T12:30:00 Z mhy908 쌀 창고 (IOI11_ricehub) C++14
0 / 100
5 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);
            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;
        ^
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -