Submission #286482

# Submission time Handle Problem Language Result Execution time Memory
286482 2020-08-30T13:10:30 Z Ruba_K Rice Hub (IOI11_ricehub) C++14
68 / 100
1000 ms 2420 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std ;


vector<int>v;
long long mx , l;
bool ok(int md){
    long long sum = 0 , mn = 1e18 ;
    int sz = v.size();
    for(int i = 0 ; i <= sz - md ; i ++){

        int mid = (i + md + i) / 2 ;
        for(int c = i ; c < md + i ; c ++){
            sum += abs(v[mid] - v[c]);
        }
        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 ;
//    vector<int>v;

    for(int i = 0 ; i < R ; i ++)
        v.push_back(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 ;

  return R;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory 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 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 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 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 256 KB Output is correct
21 Correct 31 ms 384 KB Output is correct
22 Correct 31 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 91 ms 384 KB Output is correct
28 Correct 70 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 303 ms 692 KB Output is correct
2 Correct 336 ms 768 KB Output is correct
3 Correct 27 ms 2420 KB Output is correct
4 Correct 20 ms 2420 KB Output is correct
5 Execution timed out 1080 ms 1280 KB Time limit exceeded
6 Halted 0 ms 0 KB -