nyoj 1242 Interference Signal 河南省ACM2015年省赛G题

来源:互联网 发布:c语言面试题 csdn下载 编辑:程序博客网 时间:2024/05/16 12:58

Interference Signal

时间限制:2000 ms  |  内存限制:65535 KB
难度:1
描述

Dr.Kong’s laboratory monitor some interference signals. The interference signals can be digitized into a series of positive integer. May be, there areN integers a1,a2,…,an.

 

Dr.Kong wants to know the average strength of a contiguous interference signal block.the block must contain at least M integers.

 

Please help Dr.Kong to calculate themaximum averagestrength, given the constraint.

输入
The input contains K test cases. Each test case specifies:
* Line 1: Two space-separated integers, N and M.
* Lines2~line N+1: ai (i=1,2,…,N)
1 ≤ K≤ 8, 5 ≤ N≤ 2000, 1 ≤ M ≤ N, 0 ≤ ai ≤9999
输出
For each test case generate a single line containing a single integer that is 1000 times the maximal average value. Do not perform rounding.

样例输入

2 10 66 42103859415 210385 9 

样例输出

65007333

来源
第八届河南省程序设计大赛
上传者
hnu_acm

模拟-.-发现2015年省赛好水-.-.-希望今年更水-.-




 

 

代码:

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define LL long longLL shu[4200],he[4200];int n,k,m;int main(){scanf("%d",&k);while (k--){scanf("%d%d",&n,&m);he[0]=0;for (int i=1;i<=n;i++){scanf("%lld",&shu[i]);he[i]=he[i-1]+shu[i];}LL ma=0;for (int i=m;i<=n;i++){for (int j=0;j<=n-m;j++)ma=max(ma,(he[j+i]-he[j])*1000/i);}printf("%lld\n",ma);}return 0;}


 

0 0