답안 #286737

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


vector<int>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 ++){

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

        int 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 384 KB Output is correct
3 Correct 1 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 1 ms 384 KB Output is correct
2 Correct 1 ms 384 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 1 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 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 384 KB Output is correct
13 Correct 1 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 1 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 0 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 1 ms 384 KB Output is correct
27 Correct 0 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 1 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 384 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 512 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 3064 KB Output is correct
4 Correct 19 ms 3064 KB Output is correct
5 Correct 12 ms 1664 KB Output is correct
6 Correct 9 ms 1536 KB Output is correct
7 Correct 14 ms 2808 KB Output is correct
8 Correct 15 ms 2808 KB Output is correct
9 Correct 8 ms 1532 KB Output is correct
10 Correct 9 ms 1532 KB Output is correct
11 Correct 18 ms 3192 KB Output is correct
12 Correct 19 ms 3064 KB Output is correct
13 Incorrect 9 ms 1660 KB Output isn't correct
14 Halted 0 ms 0 KB -