답안 #286738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286738 2020-08-30T20:33:04 Z Ruba_K 쌀 창고 (IOI11_ricehub) C++14
100 / 100
21 ms 3448 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std ;


vector<long long>v;
int sz;
long long mx , l , prfsum[1000000];



bool ok(int md){
    long long sum = 0 , mn = 1e18 ;

    for(int i = 0 ; i <= sz - md ; i ++){

        long long mid = (i + md + i) / 2 ;

        long long before = mid - i , after = md + i - 1 - mid ;

        sum = before * v[mid] - prfsum[mid] + prfsum[i] ;
         
        sum +=  (prfsum[md + i] - prfsum [mid + 1] - after * v[mid]);

        mn = min(mn , sum);
        sum = 0 ;


        //B : continue ;

       if(mn <= mx)return true ;
    }
    return false ;

}/*
5 20 6
1 2 10 12 14
3
*/
int besthub(int R, int L, int X[], long long B)
{   mx = B ;l = L , sz = R ;

//    vector<int>v;

    for(int i = 0 ; i < R ; i ++)
        v.push_back(X[i]) , prfsum[i + 1] = prfsum[i] + X[i];

    int l = 0 , r = R , md ;

    while(l < r){
        md = (l + r + 1) / 2 ;

        if(ok(md))l = md ;

        else r = md - 1 ;
    }




    return l ;


}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 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 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 1 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 0 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 0 ms 384 KB Output is correct
9 Correct 0 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 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 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 1 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 1 ms 384 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 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 512 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 896 KB Output is correct
2 Correct 4 ms 896 KB Output is correct
3 Correct 18 ms 2424 KB Output is correct
4 Correct 18 ms 2424 KB Output is correct
5 Correct 10 ms 1404 KB Output is correct
6 Correct 10 ms 1532 KB Output is correct
7 Correct 16 ms 2424 KB Output is correct
8 Correct 16 ms 2424 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 9 ms 1404 KB Output is correct
11 Correct 21 ms 2424 KB Output is correct
12 Correct 20 ms 2424 KB Output is correct
13 Correct 10 ms 1404 KB Output is correct
14 Correct 11 ms 1820 KB Output is correct
15 Correct 15 ms 3064 KB Output is correct
16 Correct 15 ms 3064 KB Output is correct
17 Correct 19 ms 3320 KB Output is correct
18 Correct 18 ms 3320 KB Output is correct
19 Correct 19 ms 3448 KB Output is correct
20 Correct 20 ms 3320 KB Output is correct