# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
725444 |
2023-04-17T12:48:40 Z |
Mauve |
Rice Hub (IOI11_ricehub) |
C++14 |
|
0 ms |
0 KB |
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
//using namespace __gnu_pbds;
using namespace std;
//#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define INF 4000000000000000000
#define MOD 1000000007
#define ll long long
#define pb push_back
#define A 900000011
#define ss second
#define endl '\n'
#define ff first
ll n,m,l,r,i,ii,jj,xx,yy,j,t,x,y,z,T,k,p,ans,a[100005];
bool shaa(ll k){
ll med=(k-1)/2,sum=0,ans;
for(ll i=0;i<k;i++) sum+=abs(a[med]-a[i]);
ans=sum;
for(ll i=k;i<n;i++){
sum-=(a[med]-a[i-k]);
sum+=(med-(i-k))*(a[med+1]-a[med]);
sum-=(i-1-med)*(a[med+1]-a[med]);
med++;
sum+=(a[i]-a[med]);
ans=min(ans,sum);
}
if(ans<=p) return true;
else return false;
}
int besthub(ll R, ll L, ll X[], ll B){
ll l=0,r=R,m;
for(int i=0;i<R;i++) a[i]=X[i];
n=R;
p=B;
while(r-l>1){
m=(r+l)/2;
if(shaa(m)) l=m;
else r=m-1;
}
if(shaa(r)) return r;
else return l;
}
int main(){
cin.tie(NULL);
cout.tie(NULL);
ios::sync_with_stdio(false);
}
Compilation message
/usr/bin/ld: /tmp/ccki9hjj.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCWB5Sj.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccki9hjj.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