Submission #77788

# Submission time Handle Problem Language Result Execution time Memory
77788 2018-09-30T12:11:55 Z muradeyn Rice Hub (IOI11_ricehub) C++14
17 / 100
20 ms 3500 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] + x[i - 1];
    int ret = 0;
    int le = 0,ri = r - 1;
    while (le <= ri) {
        bool f = false;
        int mid = (le + ri) >> 1;
        for (int i = 0;i<r;i++) {
            if (i + mid > r)continue;
            long long cost = 0;
            int 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;
            }
        }
        if (f) le = mid + 1;
        else ri = mid - 1;
    }
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 952 KB Output is correct
2 Correct 2 ms 952 KB Output is correct
3 Incorrect 2 ms 952 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 952 KB Output is correct
2 Correct 2 ms 952 KB Output is correct
3 Incorrect 2 ms 1012 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1276 KB Output is correct
2 Correct 6 ms 1428 KB Output is correct
3 Incorrect 20 ms 3500 KB Output isn't correct
4 Halted 0 ms 0 KB -