답안 #914726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914726 2024-01-22T15:24:47 Z DucNguyen2007 쌀 창고 (IOI11_ricehub) C++14
0 / 100
2 ms 2652 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxN=1e5+5;
ll sum[maxN+1],a[maxN+1];
ll get(ll l,ll r)
{
    return sum[r]-sum[l-1];
}
ll besthub(int L,int n,int x[],ll B)
{
    for(int i=0;i<n;i++)
    {
        a[i+1]=x[i];
    }
    sum[0]=0;
    for(int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    for(int len=1;len<=n;len++)
    {
        ll l=1,r=len;
        while(r<=n)
        {
            ll p=(l+r)/2;
            ll cur=(p-l+1)*a[p]-get(l,p)+get(p,r)-(r-p+1)*a[p];
            if(cur<=B)
            {
                return len;
            }
            l++;
            r++;
        }
    }
}

Compilation message

ricehub.cpp: In function 'long long int besthub(int, int, int*, long long int)':
ricehub.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -