답안 #880726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880726 2023-11-29T23:02:57 Z andro 쌀 창고 (IOI11_ricehub) C++14
100 / 100
10 ms 3676 KB
#include<bits/stdc++.h>
#include "ricehub.h"
 
using namespace std;
using ll = long long;
 
const int N = 100005;
ll suf[N], pref[N];
 
int besthub(int n, int L, int a[], long long c)
{
    if(n==1)return 1;
    for(int i=1; i<=n; i++){
        pref[i]=pref[i-1]+a[i-1];
    }
    for(int i=n-1; i>=0; i--){
        suf[i]=pref[n]-pref[i];
    }
    ll sufind=n;
    ll mx;
    ll s=n/2;
    ll cost=2e18;
    while(cost>c){
        s=sufind/2;
        cost=a[s]*(s+1)-pref[s+1]-a[s]*(sufind-s)+suf[s]-suf[sufind];
        if(cost<=c)break;
        sufind--;
 
    }
    mx=sufind;
    for(int i=1; i< n; i++){
        cost=0;
        while(cost<=c && sufind<n){
            s=(sufind+i)/2;
            cost=a[s]*(s-i+1)-pref[s+1]+pref[i]-a[s]*(sufind-s)+suf[s+1]-suf[sufind+1];
            sufind++;
        }
        if(sufind==n && cost<=c){
            mx=max(mx, sufind-i);
            break;
        }
        else{
            sufind--;
            mx=max(mx, sufind-i);
        }
    }
    return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2424 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2404 KB Output is correct
18 Correct 1 ms 2404 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2408 KB Output is correct
21 Correct 2 ms 2404 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2504 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 2 ms 2604 KB Output is correct
3 Correct 9 ms 3672 KB Output is correct
4 Correct 10 ms 3676 KB Output is correct
5 Correct 5 ms 2860 KB Output is correct
6 Correct 5 ms 3160 KB Output is correct
7 Correct 8 ms 3368 KB Output is correct
8 Correct 9 ms 3420 KB Output is correct
9 Correct 6 ms 2904 KB Output is correct
10 Correct 5 ms 2908 KB Output is correct
11 Correct 9 ms 3676 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 4 ms 2908 KB Output is correct
14 Correct 5 ms 2908 KB Output is correct
15 Correct 7 ms 3272 KB Output is correct
16 Correct 7 ms 3420 KB Output is correct
17 Correct 8 ms 3672 KB Output is correct
18 Correct 8 ms 3416 KB Output is correct
19 Correct 9 ms 3480 KB Output is correct
20 Correct 8 ms 3676 KB Output is correct