답안 #296629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
296629 2020-09-10T17:42:56 Z alexandra_udristoiu 쌀 창고 (IOI11_ricehub) C++14
0 / 100
5 ms 768 KB
#include "ricehub.h"
#include<algorithm>
#define DIM 100005
using namespace std;

static int v[DIM], n;
static long long sum[DIM];
long long calc(int p, int u, int i){
    return v[i] * 1LL * (u - p + 1) + (sum[u] - sum[i]) - (sum[i] - sum[p - 1]);
}
long long solve(int k){
    int i, p;
    long long minim = 100000000000000LL;
    p = 1;
    for(i = 1; i <= n - k + 1; i++){
        p = max(p, i);
        while(p < i + k - 1 && calc(i, i + k - 1, p + 1) <= calc(i, i + k - 1, p) ){
            p++;
        }
        minim = min(minim, calc(i, i + k - 1, p) );
    }
    return minim;
}

int besthub(int N, int m, int X[], long long b){
    int i, st, dr, mid;
    n = N;
    for(i = 1; i <= n; i++){
        v[i] = X[i - 1];
        sum[i] = sum[i - 1] + v[i];
    }
    st = 1;
    dr = n;
    while(st <= dr){
        mid = (st + dr) / 2;
        if( solve(mid) <= b ){
            st = mid + 1;
        }
        else{
            dr = mid - 1;
        }
    }
    return dr;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 360 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -