Submission #107412

# Submission time Handle Problem Language Result Execution time Memory
107412 2019-04-24T06:51:29 Z DodgeBallMan Rice Hub (IOI11_ricehub) C++14
100 / 100
31 ms 2552 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 100;
long long sum[N];

int check( int mid, int r, long long b, int x[] ) {
    for( int i = mid - 1 ; i < r ; i++ ) {
        int rb = i, lb = i - mid + 1;
        int m = ( rb + lb ) >> 1;
        long long cost = sum[rb+1] - sum[m+1] - sum[m] + sum[lb] + ( long long )x[m] * ( long long )( 2*m - rb - lb );
        if( cost <= b ) return 1;
    }
    return 0;
}

int besthub( int r, int l, int x[], long long b ) {
    sum[0] = 0;
    for( int i = 1 ; i <= r ; i++ ) sum[i] = sum[i-1] + ( long long )x[i-1];
    if( !check( 2, r, b, x ) ) return 1;
    int ll = 2, rr = r;
    while( ll < rr ) {
        int mid = ( ll + rr + 1 ) >> 1;
        if( check( mid, r, b, x ) ) ll = mid;
        else rr = mid - 1;
    }
    return ll;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 300 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 368 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 4 ms 512 KB Output is correct
25 Correct 4 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 31 ms 2552 KB Output is correct
4 Correct 19 ms 2552 KB Output is correct
5 Correct 10 ms 1280 KB Output is correct
6 Correct 16 ms 1280 KB Output is correct
7 Correct 14 ms 2304 KB Output is correct
8 Correct 14 ms 2304 KB Output is correct
9 Correct 9 ms 1280 KB Output is correct
10 Correct 8 ms 1280 KB Output is correct
11 Correct 19 ms 2552 KB Output is correct
12 Correct 21 ms 2552 KB Output is correct
13 Correct 14 ms 1380 KB Output is correct
14 Correct 10 ms 1408 KB Output is correct
15 Correct 17 ms 2048 KB Output is correct
16 Correct 15 ms 2048 KB Output is correct
17 Correct 17 ms 2304 KB Output is correct
18 Correct 18 ms 2304 KB Output is correct
19 Correct 17 ms 2432 KB Output is correct
20 Correct 17 ms 2432 KB Output is correct