제출 #898744

#제출 시각아이디문제언어결과실행 시간메모리
898744Sir_Ahmed_ImranRice Hub (IOI11_ricehub)C++17
25 / 100
11 ms3632 KiB
                              ///~~~LOTA~~~///
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define MAXN 100000
ll a[MAXN];
ll b[MAXN];
bool check(ll n,ll l,ll r,int v[],ll& x){
    if(l==r) return 1;
    int mid=(l+r)/2;
    ll o=a[mid]+b[mid];
    o-=a[l]+(v[mid]-v[l])*l;
    o-=b[r]+(v[r]-v[mid])*(n-r-1);
    if(o>x) return 0;
    return 1;
}
int besthub(int n,int m,int v[],ll x){
    ll o,p,q;
    a[0]=b[n-1]=o=p=q=0;
    for(int i=1;i<n;i++)
        a[i]=a[i-1]+i*(v[i]-v[i-1]);
    for(int i=n-2;i>=0;i--)
        b[i]=b[i+1]+(n-1-i)*(v[i+1]-v[i]);
    while(q<=n){
        if(check(n,p,q,v,x)){
            o=max(o,q-p);
            q++;
        }
        else p++;
    }
    return o;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...