Submission #286478

# Submission time Handle Problem Language Result Execution time Memory
286478 2020-08-30T13:06:20 Z Ruba_K Rice Hub (IOI11_ricehub) C++14
17 / 100
1000 ms 768 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 ++){
        for(int j = 1 ; j < l + 1 ; j ++){


            for(int c = i ; c < md + i ; c ++){
                sum += abs(j - 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 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
# 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 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
8 Correct 11 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 256 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 256 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 9 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 11 ms 376 KB Output is correct
20 Correct 12 ms 256 KB Output is correct
21 Correct 274 ms 376 KB Output is correct
22 Correct 316 ms 376 KB Output is correct
23 Correct 890 ms 380 KB Output is correct
24 Execution timed out 1052 ms 256 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 271 ms 376 KB Output is correct
2 Correct 314 ms 504 KB Output is correct
3 Execution timed out 1053 ms 384 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 768 KB Time limit exceeded
2 Halted 0 ms 0 KB -