답안 #843903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
843903 2023-09-04T16:45:08 Z ZeroCool 쌀 창고 (IOI11_ricehub) C++14
100 / 100
20 ms 4444 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define ll long long

const int N = 1e5 +5 ;

using namespace std;

ll pref[N];

ll sum(int a,int b){
    return pref[b] - pref[a-1];
}

int32_t besthub(int n, int l, int X[], ll k){
    ll A[n+1];

    for(int i = 1;i<=n;i++){
        A[i] = X[i-1];
        pref[i] = pref[i-1] + A[i];
    }
    ll res = 0;
    for(int i = 1;i<=n;i++){
        ll lo = i;
        ll hi = n;

        while(lo <= hi){
            ll mid = (lo + hi)/2;
            ll x = (i + mid) /2 ;
            ll val = (A[x]*(x-i) - sum(i,x-1)) + (sum(x+1, mid) - A[x] * (mid-x));

            if(val <= k){
                res = max(res, mid - i + 1);
                lo = mid + 1;
            }else{
                hi = mid - 1;
            }
        }
    }

    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2552 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2392 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 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2552 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2648 KB Output is correct
25 Correct 2 ms 2392 KB Output is correct
26 Correct 2 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2904 KB Output is correct
2 Correct 3 ms 2904 KB Output is correct
3 Correct 20 ms 4432 KB Output is correct
4 Correct 14 ms 4440 KB Output is correct
5 Correct 6 ms 3164 KB Output is correct
6 Correct 6 ms 3164 KB Output is correct
7 Correct 13 ms 4188 KB Output is correct
8 Correct 15 ms 4188 KB Output is correct
9 Correct 7 ms 3156 KB Output is correct
10 Correct 7 ms 3164 KB Output is correct
11 Correct 17 ms 4444 KB Output is correct
12 Correct 14 ms 4444 KB Output is correct
13 Correct 7 ms 3420 KB Output is correct
14 Correct 7 ms 3420 KB Output is correct
15 Correct 11 ms 3932 KB Output is correct
16 Correct 11 ms 3932 KB Output is correct
17 Correct 13 ms 4188 KB Output is correct
18 Correct 14 ms 4320 KB Output is correct
19 Correct 14 ms 4188 KB Output is correct
20 Correct 14 ms 4188 KB Output is correct