原题:
题解:
#include#include #include #define N 50005typedef long long ll;using namespace std;ll n,c[N],a[N],b[N],sum[N],f[N],L,q[N],l,r;ll sq(ll x){ return x*x;}double getD(ll j,ll k){ return 1.0*(f[j]+sq(b[j])-f[k]-sq(b[k]))/(2*(b[j]-b[k]));}int main(){ scanf("%lld%lld",&n,&L); for (ll i=1;i<=n;i++) { scanf("%lld",&c[i]); sum[i]=sum[i-1]+c[i]; a[i]=sum[i]+i-1-L; b[i]=sum[i]+i; } for (ll i=1;i<=n;i++) { while (l