Submission #95096

# Submission time Handle Problem Language Result Execution time Memory
95096 2019-01-27T09:31:18 Z Alexa2001 Rice Hub (IOI11_ricehub) C++17
100 / 100
17 ms 3420 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int Nmax = 1e5 + 5;

ll x[Nmax], s[Nmax], lim;
int n;

bool check(int nr)
{
    int i, m;
    ll curr;
    for(i=0; i<=n-nr; ++i)
    {
        m = (i + i + nr - 1) / 2;

        curr = (m - i + 1) * x[m] - (s[m] - s[i-1]);
        curr += (s[i+nr-1] - s[m]) - (i+nr-1 - m) * x[m];
        if(curr <= lim) return 1;
    }
    return 0;
}

int besthub(int R, int L, int X[], ll B)
{
    int st = 0, dr = R, mid, i;

    n = R; lim = B;
    for(i=0; i<n; ++i) x[i] = X[i], s[i] = s[i-1] + x[i];

    while(st <= dr)
    {
        mid = (st + dr) / 2;
        if(check(mid)) st = mid+1;
            else dr = mid-1;
    }
    return dr;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 292 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 16 ms 3420 KB Output is correct
4 Correct 16 ms 3320 KB Output is correct
5 Correct 9 ms 1656 KB Output is correct
6 Correct 9 ms 1656 KB Output is correct
7 Correct 13 ms 3040 KB Output is correct
8 Correct 13 ms 3064 KB Output is correct
9 Correct 8 ms 1532 KB Output is correct
10 Correct 9 ms 1656 KB Output is correct
11 Correct 17 ms 3320 KB Output is correct
12 Correct 17 ms 3320 KB Output is correct
13 Correct 9 ms 1656 KB Output is correct
14 Correct 9 ms 1656 KB Output is correct
15 Correct 13 ms 2552 KB Output is correct
16 Correct 13 ms 2556 KB Output is correct
17 Correct 15 ms 3064 KB Output is correct
18 Correct 15 ms 3064 KB Output is correct
19 Correct 17 ms 3192 KB Output is correct
20 Correct 16 ms 3192 KB Output is correct