Submission #129332

# Submission time Handle Problem Language Result Execution time Memory
129332 2019-07-12T03:54:43 Z arnold518 Rice Hub (IOI11_ricehub) C++14
100 / 100
48 ms 1292 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, L, X[MAXN+10], ans=1;
ll B;

int besthub(int RR, int LL, int XX[], ll BB)
{
    int i, j;
    N=RR; L=LL; B=BB;
    for(i=0; i<N; i++) X[i]=XX[i];

    ll cost=0;
    int lp=0, rp=0;
    for(; lp<N; lp++)
    {
        //printf("%d %d %lld\n", lp, rp, cost);
        for(; rp<N && cost<=B; rp++)
        {
            //printf("%d %d %lld\n", lp, rp, cost);
            ans=max(ans, rp-lp+1);
            int mid=(lp+rp+1)>>1;
            cost+=X[rp+1]-X[mid];
        }
        //printf("%d %d %lld\n", lp, rp, cost);
        int mid=(lp+rp+1)>>1;
        cost-=X[mid]-X[lp];
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
# 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 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 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 3 ms 476 KB Output is correct
8 Correct 2 ms 256 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 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 4 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 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 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 376 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 380 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 292 KB Output is correct
8 Correct 2 ms 296 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 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 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 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
3 Correct 17 ms 1272 KB Output is correct
4 Correct 17 ms 1292 KB Output is correct
5 Correct 8 ms 888 KB Output is correct
6 Correct 10 ms 796 KB Output is correct
7 Correct 15 ms 1264 KB Output is correct
8 Correct 15 ms 1272 KB Output is correct
9 Correct 8 ms 888 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 20 ms 1272 KB Output is correct
12 Correct 19 ms 1272 KB Output is correct
13 Correct 9 ms 888 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 15 ms 1144 KB Output is correct
16 Correct 15 ms 1144 KB Output is correct
17 Correct 18 ms 1292 KB Output is correct
18 Correct 48 ms 1272 KB Output is correct
19 Correct 18 ms 1272 KB Output is correct
20 Correct 18 ms 1272 KB Output is correct