답안 #481896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481896 2021-10-22T07:30:36 Z uHyHn 쌀 창고 (IOI11_ricehub) C++14
0 / 100
6 ms 1100 KB
#include<bits/stdc++.h>

//IBOW
#define Task "IOI11_RICEHUB"
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define eb emplace_back

using namespace std;

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

const int N = 2e5 + 10;
const int inf = 2e9 + 10;
const ll INF = 2e18 + 10;
const int MOD = 1e9 + 7;

bool ok(int va, int n, int l, int x[], ll B, ll pre[])
{
    ll mn = INF;
    for (int i = va; i <= n; ++i)
    {
        int rr = i;
        int ll = i - va + 1;
        int median = (rr + ll) / 2;
        for (int j = median - 1; j <= median + 1; ++j)
        {
            mn = min(mn, x[j] * 1LL * (j - ll + 1) - (pre[j] - pre[ll - 1]) + (pre[rr] - pre[j]) - x[j] * 1LL * (rr - j));
        }
    }
    return mn <= B;
}
int besthub(int n, int l, int x[], ll B)
{
    ll pre[100010] = {};
    for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + x[i];
    int L = 1, R = n, ans = -1;
    while (L <= R)
    {
        int mid = (L + R) / 2;
        if (ok(mid, n, l, x, B, pre))
            L = mid + 1, ans = mid;
        else R = mid - 1;
    }
    return ans;
//    return 0;
}



# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB Output isn't correct
2 Halted 0 ms 0 KB -