Submission #16999

# Submission time Handle Problem Language Result Execution time Memory
16999 2015-11-03T17:51:14 Z erdemkiraz Rice Hub (IOI11_ricehub) C++
0 / 100
4 ms 6800 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;

#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;
typedef pair < int, int > ii;

const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;

const int N = 1e5 + 5;

int n;
int a[N];
ll m;
ll L[N];

int ptr, ans = 1;

ll getL(int i, int j) {
    return (ll) (j - i + 1) * a[j] - (L[j] - L[i - 1]);
}

ll getR(int i, int j) {
    return L[j] - L[i - 1] - (ll) (j - i + 1) * a[i];
}

bool check(int i, int j) {
    ptr = max(ptr, j);
    ll need = getL(i, j);
    if(need > m)
        return 0;
    while(ptr + 1 <= n and a[ptr + 1] - a[j] <= a[j] - a[i]) {
        ptr++;
        ans = max(ans, ptr - i + 1);
    }
    return 1;
}

void solve() {
    for(int i = 1; i <= n; i++)
        L[i] = L[i - 1] + a[i];
    :: ptr = 1;
    int ptr = 1;
    for(int i = 1; i <= n; i++) {
        ptr = max(ptr, i);
        while(ptr + 1 <= n and check(i, ptr + 1))
            ptr++;
    }
}

int besthub(int R, int L, int X[], long long B) {
    n = R;
    m = B;
    for(int i = 0; i < n; i++) {
        a[i + 1] = X[i];
        X[i] = L - X[i] + 1;
    }
    for(int i = 1; i <= n; i++) {
        a[i] = X[n - i];
    }
    solve();
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6800 KB Output is correct
2 Incorrect 0 ms 6800 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6800 KB Output is correct
2 Correct 0 ms 6800 KB Output is correct
3 Correct 0 ms 6800 KB Output is correct
4 Incorrect 0 ms 6800 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 6800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6800 KB Output isn't correct
2 Halted 0 ms 0 KB -