G.Interference Signal

时间限制: 2 Sec  内存限制: 128 MB
提交: 47  解决: 18
[提交][状态]

题目描述

Dr.Kong’s laboratory monitor some interference signals. The interference signals can be digitized into a series of positive integer. May be, there are N 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 the maximum average strength, 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

输出

the maximum average strength

样例输入

2
10 6
6
4
2
10
3
8
5
9
4
1
5 2
10
3
8
5
9

样例输出

6500
7333
题目大意: 求连续序列大于等于k个的最大平均 值
dp[i][j] 表示在j的位置的i个连续序列的最大和 dp[i][j] = max(dp[i-1][j-1] + a[j], dp[i][j]) 只要公式推出来就很容易了
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include <queue> using namespace std;
#define N 2500
#define ESP 1e-8
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a)) int a[N];
int dp[N][N]; int main()
{
int T,n,k;
scanf ("%d", &T);
while(T --)
{
scanf("%d %d", &n, &k);
for(int i=; i<=n; i++)
scanf("%d", &a[i]); memset(dp, ); dp[][]=a[]; for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
dp[i][j] = max(dp[i][j], dp[i-][j-]+a[j]);
}
} double Max=; for(int i=k; i<=n; i++)
{
for(int j=i; j<=n; j++)
{
Max = max(Max, dp[i][j]*1.0/i*1.0);
}
} printf("%d\n", (int)(Max*1000.0));
}
return ;
}
 

G.Interference Signal---河南省第八届程序设计大赛(dp)的更多相关文章

  1. 第八届河南省赛G.Interference Signal(dp)

    G.Interference Signal Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 35  Solved: 17 [Submit][Status ...

  2. 谁才是最强战舰!-From 南京理工大学第八届程序设计大赛(校外镜像),博弈~~

    谁才是最强战舰! Time Limit: 1000MS Memory Limit: 65536KB Description 依阿华来到镇守府的第一件事情,就是找大和solo!然而这并不是什么好消息,说 ...

  3. 每天一套题打卡|河南省第八届ACM/ICPC

    A 挑战密室 化学方程式求分子量 这题我懒得写了 可以用map<string,int>哈希表,表示每种分子的相对分子质量 之后,从头遍历到尾. 1.数字:连读直到不是数字 2.字母:连读直 ...

  4. NYOJ--1236--挑战密室(第八届河南省程序设计大赛)

    挑战密室 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 R组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室.Dr. Kong必须尽快找到解锁密 ...

  5. nyoj 1239 引水project (河南省第八届acm程序设计大赛)

    题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...

  6. nyoj1237 最大岛屿(河南省第八届acm程序设计大赛)

    题目1237 pid=1237" style="color:rgb(55,119,188)">题目信息 执行结果 本题排行 讨论区 最大岛屿 时间限制:1000 m ...

  7. 第八届河南省程序设计大赛-B.最大岛屿0000110011000000

    最大岛屿                                                                                           时间限制: ...

  8. nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)

    题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...

  9. 河南省第八届ACM程序设计大赛

    A:挑战密室 #include <iostream> #include <cstdio> #include <cstring> #include <algor ...

随机推荐

  1. struts2.3.4,jar包必须添加完整

  2. pascal闪电入门系列目录

    第一章  准备工作 第二章  Hello,world! 第三章  输出.输入 第四章  变量常量.基本数据类型 第五章  格式.注释 第六章  运算符.表达式.优先级 第七章  分支结构 第八章  数 ...

  3. js浏览器对象的属性和方法

    1.window对象 /*1.计算浏览器窗口大小*/ //不算滚动条: var width = window.innerWidth; var height = window.innerHeight; ...

  4. 【英语魔法俱乐部——读书笔记】 2 中级句型-复句&合句(Complex Sentences、Compound Sentences)

    [英语魔法俱乐部——读书笔记] 2 中级句型-复句&合句(Complex Sentences.Compound Sentences):(2.1)名词从句.(2.2)副词从句.(2.3)关系从句 ...

  5. machine leanring 笔记 octave命令笔记

    来源于coursea 的公开课 A*B 一般意义的矩阵相乘 A.*B矩阵各位相乘 A.^2 A矩阵的每个数平方 1./A  对A矩阵的各位取倒 .表示对每一项都如此操作 log (A) exp(A) ...

  6. 将mac上的项目上传到oschina,进行代码托管。

    1.首先看一下自己是否有公钥, 在 我的资料-->SSH公钥  查看,如果没有,添加自己的SSH 公钥: SSH key 可以让你在你的电脑和 Git @ OSC 之间建立安全的加密连接. 2. ...

  7. div+css的第一个布局

    ---恢复内容开始--- 这个东西说难也不难,但也要详细思虑一番: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/ ...

  8. centos7安装数据库

    centos7的yum源中貌似没有正常安装MySQL时的mysql-server. 那么就需要从官网下载了. 下面是安装mysql的命令: # wget http://dev.mysql.com/ge ...

  9. tcp转发

    Proxy.java package com.dc.tcp.proxy; import java.io.IOException; import java.net.ServerSocket; impor ...

  10. NSURLCache详解和使用

    使用缓存的目的是为了使应用程序能更快速的响应用户输入,是程序高效的运行.有时候我们需要将远程web服务器获取的数据缓存起来,以空间换取时间,减少对同一个url多次请求,减轻服务器的压力,优化客户端网络 ...