G.Interference Signal---河南省第八届程序设计大赛(dp)
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)的更多相关文章
- 第八届河南省赛G.Interference Signal(dp)
G.Interference Signal Time Limit: 2 Sec Memory Limit: 128 MB Submit: 35 Solved: 17 [Submit][Status ...
- 谁才是最强战舰!-From 南京理工大学第八届程序设计大赛(校外镜像),博弈~~
谁才是最强战舰! Time Limit: 1000MS Memory Limit: 65536KB Description 依阿华来到镇守府的第一件事情,就是找大和solo!然而这并不是什么好消息,说 ...
- 每天一套题打卡|河南省第八届ACM/ICPC
A 挑战密室 化学方程式求分子量 这题我懒得写了 可以用map<string,int>哈希表,表示每种分子的相对分子质量 之后,从头遍历到尾. 1.数字:连读直到不是数字 2.字母:连读直 ...
- NYOJ--1236--挑战密室(第八届河南省程序设计大赛)
挑战密室 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 R组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室.Dr. Kong必须尽快找到解锁密 ...
- nyoj 1239 引水project (河南省第八届acm程序设计大赛)
题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...
- nyoj1237 最大岛屿(河南省第八届acm程序设计大赛)
题目1237 pid=1237" style="color:rgb(55,119,188)">题目信息 执行结果 本题排行 讨论区 最大岛屿 时间限制:1000 m ...
- 第八届河南省程序设计大赛-B.最大岛屿0000110011000000
最大岛屿 时间限制: ...
- nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)
题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...
- 河南省第八届ACM程序设计大赛
A:挑战密室 #include <iostream> #include <cstdio> #include <cstring> #include <algor ...
随机推荐
- lamp 安装 apache php
http://www.cnblogs.com/CheeseZH/p/4694135.html
- WinForm中WebBrowser的使用
最近由于工作需要,研究了下Winform的WebBrowser控件,在这里给大家分享下. 1.WebBrowser导航 WebBrowser在进行导航的时候需要用到Navigate(string ur ...
- SQL Server类型的对应关系
bit bool tinyint byte smallint short int int bigint long real float float double money decimal datet ...
- 协同开发中SVN的使用建议
协同开发中SVN的使用建议 1. 注意个人账户密码安全 各员工需牢记各自的账户和密码,不得向他人透漏,严禁使用他人账户进行SVN各项操作(主要考虑每个SVN账号的使用者的权限范围问题).如有忘记,请 ...
- Java Web 环境搭建步骤(超详细,包括前期安装步骤)
Java Web 环境搭建步骤 安装对应版本的JDK 配置环境变量 本人安装的路径是C盘,在path中加入C:\Program Files\Java\jdk1.8.0_65\bin 测试配置成功,cm ...
- URLError 异常处理
3 URLError 首先解释下 URLError 可能产生的原因: 网络无连接,即本机无法上网 连接不到特定的服务器 服务器不存在 在代码中,我们需要用 try-except 语句来包围并捕获相应的 ...
- c#FileStream文件读写(转)
FileStream对象表示在磁盘或网络路径上指向文件的流.这个类提供了在文件中读写字节的方法,但经常使用StreamReader或StreamWriter执行这些功能.这是因为FileStream类 ...
- eclipse中的 Compiler compliance level含义
The compiler compliance setting tells the compiler to pretend it's a different version of Java. The ...
- [测]jieba分词
import jieba import os import jieba.analyse with open('src.txt', 'r') as file: data = file.read() se ...
- Spring+springmvc+Mybatis整合案例 annotation版(myeclipse)详细版
Spring+springmvc+Mybatis整合案例 Version:annotation版 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version=&qu ...