Calculate the maximum mean subsequence with a length of N, and the minimum length of the subsequence is F.
Similar to the maximum continuous field and Practice
# Include <iostream> <br/> # define maxn 100010 <br/> using namespace STD; <br/>__ int64 A [maxn], sum [maxn]; <br/> int main () <br/> {<br/>__ int64 n, m, I, J, K, S, ncows, nfields; <br/> scanf ("% i64d % i64d", & N, & M); <br/> for (I = 0; I <n; I ++) <br/> scanf ("% i64d", & A [I]); <br/> for (sum [m-1] = I = 0; I <m; I ++) <br/> sum [m-1] + = A [I]; <br/> for (; I <n; I ++) <br/> sum [I] = sum [I-1]-A [I-m] + A [I]; <br/> for (I = m, S = ncows = sum [I-1], j = nfields = I; I <n; I ++) <br/> {<br/> If (S + A [I]) * m <sum [I] * (J + 1 )) <br/> S = sum [I], j = m; <br/> else <br/> S + = A [I], J ++; <br/> If (S * nfields> ncows * j) <br/> ncows = s, nfields = J; <br/>}< br/> printf ("% i64d/N", 1000 * ncows/nfields); <br/> return 0; <br/>}