Submission #418614

# Submission time Handle Problem Language Result Execution time Memory
418614 2021-06-05T15:48:21 Z TLP39 Rice Hub (IOI11_ricehub) C++14
100 / 100
15 ms 2508 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll r,l,b;
ll qs[100010]={};

ll get_dist(ll st,ll ed)
{
    ll mid=(st+ed)>>1;
    ll med=qs[mid+1]-qs[mid];
    return med*((ed-st+1)&1ll)+(qs[ed+1]-qs[mid+1])-(qs[mid+1]-qs[st]);
}

ll hi,low,av;

bool test_b(ll k)
{
    for(ll i=0;i<=r-k;i++)
    {
        if(get_dist(i,i+k-1)<=b) return true;
    }
    return false;
}

int besthub(int R, int L, int X[], long long B)
{
    r=(ll)R;
    l=(ll)L;
    b=B;
    for(int i=0;i<r;i++)
    {
        qs[i+1]=qs[i]+(ll)X[i];
    }
    hi=r;
    low=1;
    while(hi>low)
    {
        av=(hi+low+1)>>1;
        if(test_b(av)) low=av;
        else hi=av-1;
    }
    return (int)hi;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 300 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 3 ms 588 KB Output is correct
3 Correct 14 ms 2504 KB Output is correct
4 Correct 15 ms 2508 KB Output is correct
5 Correct 8 ms 1228 KB Output is correct
6 Correct 7 ms 1092 KB Output is correct
7 Correct 12 ms 2124 KB Output is correct
8 Correct 13 ms 2192 KB Output is correct
9 Correct 8 ms 1100 KB Output is correct
10 Correct 7 ms 1100 KB Output is correct
11 Correct 15 ms 2432 KB Output is correct
12 Correct 15 ms 2504 KB Output is correct
13 Correct 8 ms 1228 KB Output is correct
14 Correct 8 ms 1228 KB Output is correct
15 Correct 13 ms 1868 KB Output is correct
16 Correct 11 ms 1988 KB Output is correct
17 Correct 13 ms 2252 KB Output is correct
18 Correct 14 ms 2276 KB Output is correct
19 Correct 13 ms 2316 KB Output is correct
20 Correct 14 ms 2392 KB Output is correct