Submission #77797

# Submission time Handle Problem Language Result Execution time Memory
77797 2018-09-30T13:16:29 Z muradeyn Rice Hub (IOI11_ricehub) C++14
100 / 100
36 ms 14612 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define SIZE 100001

using namespace std;

int besthub(int r, int l, int x[], long long b)
{
    long long pre[r + 1];
    pre[0] = 0;
    for (int i = 1;i<=r;i++)pre[i] = pre[i - 1] + 1LL*x[i - 1];
    int ret = 0;
    long long le = 1,ri = r;
    while (le <= ri) {
        bool f = false;
        int mid = (le + ri) / 2;
        //cout<<le<<" "<<ri<<" "<<mid<<endl;
        for (int i = 0;i<r;i++) {
            if (i + mid > r)continue;
            long long cost = 0;
            long long st = i , en = i + mid - 1 , med = (st + en) / 2;
            cost += (med - st) * x[med];
            cost -= pre[med] - pre[st];
            cost += pre[en + 1] - pre[med + 1];
            cost -= (en - med) * x[med];
            if (cost <= b) {
                ret = max(ret,mid);
                f = true;
            }
        }
        //cout<<f<<endl;
        if (f) le = mid + 1;
        else ri = mid - 1;
    }
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 480 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 668 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 2 ms 668 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 700 KB Output is correct
13 Correct 2 ms 700 KB Output is correct
14 Correct 2 ms 700 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 764 KB Output is correct
17 Correct 2 ms 764 KB Output is correct
18 Correct 2 ms 784 KB Output is correct
19 Correct 2 ms 784 KB Output is correct
20 Correct 2 ms 784 KB Output is correct
21 Correct 2 ms 784 KB Output is correct
22 Correct 2 ms 784 KB Output is correct
23 Correct 2 ms 812 KB Output is correct
24 Correct 2 ms 816 KB Output is correct
25 Correct 2 ms 820 KB Output is correct
26 Correct 2 ms 824 KB Output is correct
27 Correct 2 ms 948 KB Output is correct
28 Correct 2 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 948 KB Output is correct
2 Correct 2 ms 948 KB Output is correct
3 Correct 2 ms 948 KB Output is correct
4 Correct 2 ms 948 KB Output is correct
5 Correct 2 ms 948 KB Output is correct
6 Correct 2 ms 948 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 2 ms 980 KB Output is correct
12 Correct 3 ms 980 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
14 Correct 2 ms 980 KB Output is correct
15 Correct 2 ms 980 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 2 ms 980 KB Output is correct
18 Correct 2 ms 980 KB Output is correct
19 Correct 2 ms 980 KB Output is correct
20 Correct 2 ms 988 KB Output is correct
21 Correct 3 ms 996 KB Output is correct
22 Correct 3 ms 1020 KB Output is correct
23 Correct 3 ms 1060 KB Output is correct
24 Correct 3 ms 1096 KB Output is correct
25 Correct 3 ms 1124 KB Output is correct
26 Correct 3 ms 1164 KB Output is correct
27 Correct 3 ms 1204 KB Output is correct
28 Correct 4 ms 1248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1416 KB Output is correct
2 Correct 5 ms 1416 KB Output is correct
3 Correct 19 ms 2360 KB Output is correct
4 Correct 20 ms 3464 KB Output is correct
5 Correct 12 ms 3464 KB Output is correct
6 Correct 12 ms 3588 KB Output is correct
7 Correct 17 ms 4952 KB Output is correct
8 Correct 19 ms 5732 KB Output is correct
9 Correct 11 ms 5732 KB Output is correct
10 Correct 10 ms 5732 KB Output is correct
11 Correct 21 ms 7300 KB Output is correct
12 Correct 22 ms 8392 KB Output is correct
13 Correct 13 ms 8392 KB Output is correct
14 Correct 12 ms 8564 KB Output is correct
15 Correct 16 ms 9592 KB Output is correct
16 Correct 16 ms 10508 KB Output is correct
17 Correct 19 ms 11568 KB Output is correct
18 Correct 19 ms 12512 KB Output is correct
19 Correct 36 ms 13584 KB Output is correct
20 Correct 21 ms 14612 KB Output is correct