Submission #237066

# Submission time Handle Problem Language Result Execution time Memory
237066 2020-06-04T11:34:31 Z nicolaalexandra Rice Hub (IOI11_ricehub) C++14
0 / 100
28 ms 2560 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define DIM 200010
using namespace std;

long long sp[DIM];

long long get_sum (int x, int y){
    if (x > y)
        return 0;

    long long val = sp[y];
    if (x > 0)
        val -= sp[x-1];
    return val;

}
int besthub (int n, int l, int v[], long long b){
    int i, maxi = 0;
    for (i=0;i<n;i++)
        sp[i] = sp[i-1] + v[i];

    for (i=0;i<n;i++){
        int st = 0, dr = i-1, sol = i;
        while (st <= dr){
            int mid = (st+dr)>>1;
            if (1LL*(i-mid)*v[i] - get_sum(mid,i-1) <= b){
                sol = mid;
                dr = mid-1;
            } else st = mid+1;
        }

        long long val = b - ( 1LL*(i-sol)*v[i] - get_sum(sol,i-1) );
        int nr = i-sol+1;

        /// vad cat pot sa ma mai duc in dreapta
        st = i+1, dr = n-1, sol = i;
        while (st <= dr){
            int mid = (st+dr)>>1;
            if (get_sum(i+1,mid) - v[i]*(mid-i) <= val){
                sol = mid;
                st = mid+1;
            } else dr = mid-1;
        }

        nr += sol - i;

        maxi = max (maxi,nr);

    }

    return maxi;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Incorrect 4 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Incorrect 4 ms 384 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 276 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 5 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 768 KB Output is correct
2 Correct 9 ms 768 KB Output is correct
3 Correct 26 ms 2560 KB Output is correct
4 Incorrect 28 ms 2560 KB Output isn't correct
5 Halted 0 ms 0 KB -