Submission #285042

#TimeUsernameProblemLanguageResultExecution timeMemory
285042Bill_00Rice Hub (IOI11_ricehub)C++14
0 / 100
598 ms4444 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define MAX_R 1000000 int besthub(int R, int L, int a[], long long B) { int dp[100001]; dp[0]=0; for(int i=1;i<R;i++){ dp[i]=dp[i-1]+a[i]-a[0]; } int l=1,r=R; while(l!=r){ int mid=(l+r)>>1,flag=0; for(int i=mid-1;i<R;i++){ int MID=(i*2+1-mid)>>1; int left=i+1-mid; int cost=dp[i]-dp[MID]-((i-MID)*(a[MID]-a[0]))+((a[MID]-a[left])*(MID-left+1)-(dp[MID]-dp[left]-(MID-left)*(a[left]-a[0]))); cout << cost << ' ' << i << ' ' << mid << endl; if(cost<=B){ flag++; break; } } if(flag==0) r=mid; else l=mid+1; } return l-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...