답안 #307681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307681 2020-09-29T05:02:29 Z juggernaut 쌀 창고 (IOI11_ricehub) C++14
68 / 100
22 ms 2816 KB
#include"ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[100005];
ll b,pref[100005],suff[100005];
ll pref_calc(ll l,ll r){
    return pref[r]-(l-1)*(a[r]-a[l-1])-pref[l-1];
}
ll suff_calc(ll l,ll r){
    return suff[l]-(n-r)*(a[r+1]-a[l])-suff[r+1];
}
bool app(ll l,ll r){
    ll i=(l+r)>>1;
    ll mn=pref_calc(l,i)+suff_calc(i,r);
    return mn<=b;
}
bool check(int x){
    bool flag=0;
    for(int i=1;i+x-1<=n;i++)flag|=app(i,x+i-1);
    return flag;
}
int besthub(int N,int L,int A[],ll B){
    n=N;b=B;
    for(int i=0;i<n;i++)a[i+1]=A[i];
    for(int i=1;i<=n;i++)
        pref[i]=pref[i-1]+(i-1)*(a[i]-a[i-1]);
    for(int i=n;i>=1;i--)
        suff[i]=suff[i+1]+(n-i)*(a[i+1]-a[i]);
    int l=1,r=n,m;
    while(l<r){
        m=(l+r+1)>>1;
        if(check(m))l=m;
        else r=m-1;
    }
    return l;
}
//#include"grader.cpp"
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 360 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 19 ms 2688 KB Output is correct
4 Correct 19 ms 2688 KB Output is correct
5 Correct 11 ms 1536 KB Output is correct
6 Correct 11 ms 1448 KB Output is correct
7 Correct 17 ms 2816 KB Output is correct
8 Correct 17 ms 2688 KB Output is correct
9 Correct 10 ms 1536 KB Output is correct
10 Correct 10 ms 1536 KB Output is correct
11 Correct 21 ms 2688 KB Output is correct
12 Incorrect 22 ms 2680 KB Output isn't correct
13 Halted 0 ms 0 KB -