Submission #5037

# Submission time Handle Problem Language Result Execution time Memory
5037 2014-01-29T04:26:36 Z tncks0121 Rice Hub (IOI11_ricehub) C++
100 / 100
28 ms 6556 KB
#include<stdio.h>
 
typedef unsigned long long llu;
 
#define N_ 100000
int N; llu K; 
llu S[N_+1], D[N_+1];
int res;
#define sum(a,b) (S[b] - S[(a)-1])
 
typedef long long ll;

int besthub (int R, int L, int *X, ll B) {
    int i;
 
    N = R; K = B;
    for(i=1; i<=N; i++){
        D[i] = X[i-1];
        S[i] = S[i-1] + D[i];
    }
 
    for(i=1; i<=N; i++){
        int left=i, right=N;
        while(left <= right){
            int mid = (left+right)>>1;
            int x = (i+mid)>>1;
            llu val = (D[x]*(x-i) - sum(i,x-1)) + (sum(x+1, mid) - D[x] * (mid-x));
            if(val <= K){
                if(res < mid - i + 1) res = mid - i + 1;
                left = mid + 1;
            }else right = mid - 1;
        }
    }
 
    return res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6556 KB Output is correct
2 Correct 0 ms 6556 KB Output is correct
3 Correct 0 ms 6556 KB Output is correct
4 Correct 0 ms 6556 KB Output is correct
5 Correct 0 ms 6556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6556 KB Output is correct
2 Correct 0 ms 6556 KB Output is correct
3 Correct 0 ms 6556 KB Output is correct
4 Correct 0 ms 6556 KB Output is correct
5 Correct 0 ms 6556 KB Output is correct
6 Correct 0 ms 6556 KB Output is correct
7 Correct 0 ms 6556 KB Output is correct
8 Correct 0 ms 6556 KB Output is correct
9 Correct 0 ms 6556 KB Output is correct
10 Correct 0 ms 6556 KB Output is correct
11 Correct 0 ms 6556 KB Output is correct
12 Correct 0 ms 6556 KB Output is correct
13 Correct 0 ms 6556 KB Output is correct
14 Correct 0 ms 6556 KB Output is correct
15 Correct 0 ms 6556 KB Output is correct
16 Correct 0 ms 6556 KB Output is correct
17 Correct 0 ms 6556 KB Output is correct
18 Correct 0 ms 6556 KB Output is correct
19 Correct 0 ms 6556 KB Output is correct
20 Correct 0 ms 6556 KB Output is correct
21 Correct 0 ms 6556 KB Output is correct
22 Correct 0 ms 6556 KB Output is correct
23 Correct 0 ms 6556 KB Output is correct
24 Correct 0 ms 6556 KB Output is correct
25 Correct 0 ms 6556 KB Output is correct
26 Correct 0 ms 6556 KB Output is correct
27 Correct 0 ms 6556 KB Output is correct
28 Correct 0 ms 6556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6556 KB Output is correct
2 Correct 0 ms 6556 KB Output is correct
3 Correct 0 ms 6556 KB Output is correct
4 Correct 0 ms 6556 KB Output is correct
5 Correct 0 ms 6556 KB Output is correct
6 Correct 0 ms 6556 KB Output is correct
7 Correct 0 ms 6556 KB Output is correct
8 Correct 0 ms 6556 KB Output is correct
9 Correct 0 ms 6556 KB Output is correct
10 Correct 0 ms 6556 KB Output is correct
11 Correct 0 ms 6556 KB Output is correct
12 Correct 0 ms 6556 KB Output is correct
13 Correct 0 ms 6556 KB Output is correct
14 Correct 0 ms 6556 KB Output is correct
15 Correct 0 ms 6556 KB Output is correct
16 Correct 0 ms 6556 KB Output is correct
17 Correct 0 ms 6556 KB Output is correct
18 Correct 0 ms 6556 KB Output is correct
19 Correct 0 ms 6556 KB Output is correct
20 Correct 0 ms 6556 KB Output is correct
21 Correct 0 ms 6556 KB Output is correct
22 Correct 0 ms 6556 KB Output is correct
23 Correct 0 ms 6556 KB Output is correct
24 Correct 0 ms 6556 KB Output is correct
25 Correct 0 ms 6556 KB Output is correct
26 Correct 0 ms 6556 KB Output is correct
27 Correct 0 ms 6556 KB Output is correct
28 Correct 0 ms 6556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6556 KB Output is correct
2 Correct 4 ms 6556 KB Output is correct
3 Correct 24 ms 6556 KB Output is correct
4 Correct 20 ms 6556 KB Output is correct
5 Correct 12 ms 6556 KB Output is correct
6 Correct 12 ms 6556 KB Output is correct
7 Correct 20 ms 6556 KB Output is correct
8 Correct 20 ms 6556 KB Output is correct
9 Correct 12 ms 6556 KB Output is correct
10 Correct 8 ms 6556 KB Output is correct
11 Correct 28 ms 6556 KB Output is correct
12 Correct 28 ms 6556 KB Output is correct
13 Correct 12 ms 6556 KB Output is correct
14 Correct 12 ms 6556 KB Output is correct
15 Correct 20 ms 6556 KB Output is correct
16 Correct 16 ms 6556 KB Output is correct
17 Correct 24 ms 6556 KB Output is correct
18 Correct 24 ms 6556 KB Output is correct
19 Correct 20 ms 6556 KB Output is correct
20 Correct 28 ms 6556 KB Output is correct