@LIUHUAN
2019-05-12T00:34:20.000000Z
字数 1303
阅读 736
algorithm
依据递推公式
int maxRotateFunction(vector<int>& A) {
int n = A.size();
long maxv = 0;
long sum = 0;
long f = 0;
for(int i = 0; i < n; i++ ) {
sum += A[i];
long t = i;
f += t * A[i];
}
maxv = f;
for(int i = 1; i < n; i++ ) {
long t = n;
t *= A[n-i];
f = f + sum - t;
maxv = max(f,maxv);
}
return maxv;
}