# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
542672 |
2022-03-27T13:21:10 Z |
neki |
Rice Hub (IOI11_ricehub) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define par pair<ll, ll>
#define ld long double
#define mod 998244353
ll besthub(int n, int L, vc<int> X, int B){
vc<ll> x(n+1, 0);
loop(i, 0, n) x[i+1]=X[i];
vc<ll> pr=x;
loop(i, 1, n+1) pr[i]+=pr[i-1];
function<ll (ll, ll)> query=[&](ll l, ll r){
return pr[r] - pr[l-1];
};
function<ll (ll, ll)> cost=[&](ll l, ll r){
ll mid=(l+r)/2;
ll ret=0;
if(l<mid) ret+=(mid-l) * x[mid] - query(l, mid-1);
if(mid<r) ret+=query(mid+1, r) - (r-mid) * x[mid];
return ret;
};
ll r=1, ans=0;
loop(l, 1, n+1){
while(r+1<=n and cost(l, r+1)<=(ll)B) ++r;
ans=max(ans, r-l+1);
}
return ans;
}
Compilation message
/usr/bin/ld: /tmp/ccR1HDGk.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status