답안 #259200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259200 2020-08-07T11:17:27 Z Hehehe 쌀 창고 (IOI11_ricehub) C++14
0 / 100
3 ms 896 KB
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
//#define int long long
#include "ricehub.h"

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

const ll inf = 2e9;
const ll mod = 1e9 + 7;
const int N = 2e6 + 11;
const ll INF64 = 3e18 + 1;
const double eps = 1e-14;
const double PI = acos(-1);

//ifstream in(".in");
//ofstream out(".out");

ll x[N], s[N];

ll get(int x, int y){
    if(x > y)return 0;
    return s[y] - s[x - 1];
}

bool ok(int k, int n, int b){

    for(int l = 1; l <= n - k + 1; l++){
        int r = l + k - 1;
        int m = (l + r) >> 1; //location

        ll cur = 0;
        cur = x[m]*(m - l) - get(l, m - 1);
        cur += get(r, m + 1) - x[m]*(r - m);

        if(cur <= b)return 1;
    }

    return 0;
}

int besthub (int n, int L, int X[], long long b){

    for(int i = 1; i <= n; i++){
        x[i] = X[i - 1];
    }

    for(int i = 1; i <= n; i++){
        s[i] = s[i - 1] + x[i];
    }

    ll l = 1, r = n, ans = 1;
    while(l <= r){

        int mid = (l + r) >> 1;

        if(ok(mid, n, b)){
            ans = mid;
            l = mid + 1;
        }else r = mid - 1;
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -