Submission #679095

# Submission time Handle Problem Language Result Execution time Memory
679095 2023-01-07T12:27:24 Z jiahng Rice Hub (IOI11_ricehub) C++14
0 / 100
3 ms 640 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;


int R,L,B;
long long ss[maxn];
bool pos(int x){
    FOR(i,1,R+1-x){
        // [i, i+x-1]
        int med = i+(x-1)/2;
        ll cost = med * (med-i+1) - (ss[med] - ss[i-1]);
        cost += (ss[i+x-1] - ss[med]) - med*(i+x-1-med);
        if (cost <= B) return 1;
    }
    return 0;
}
int besthub(int R, int L, int X[], long long B){
    ::R = R; ::L = L; ::B = B;
    FOR(i,1,R) ss[i] = ss[i-1] + X[i-1];
    int l = 1, r = R+1;
    while (l + 1 < r){
        int m = (l + r) / 2;
        if (pos(m)) l = m;
        else r = m;
    }
    return l;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -