Farmer John's farm consists of a long row of N fields. Each field contains a certain number of cows,1≤ncows≤20001 leq ncows leq 20001≤ncows≤2000. FJ wants to build a fence around a contiguous group of these fields in order to maximize the average number of cows per field within that block. The block must contain at least F fields, where F given as input. Calculate the fence placement that maximizes the average, given the constraint.
Farmer John's farm consists of a long row of N (1≤N≤100,000)(1leq N leq 100,000)(1≤N≤100,000)fields. Each field contains a certain number of cows,1≤ncows≤20001 leq ncows leq 20001≤ncows≤2000. FJ wants to build a fence around a contiguous group of these fields in order to maximize the average number of cows per field within that block. The block must contain at least F (1≤F≤N)(1 leq F leq N)(1≤F≤N) fields, where F given as input. Calculate the fence placement that maximizes the average, given the constraint.
(图片来源网络,侵删)