HDU-2182-Frog
链接:https://vjudge.net/problem/HDU-2182
题意:
有一只青蛙,有n个节点,开始时在1节点,有k次往右跳的机会,每次跳的距离是a-b之间。
每个节点有一个值,到达那个节点则总值加上那个值。
求最大能得到的值
思路:
dp[i][j]表示第i个节点,第j次跳跃得到的值。
dp[1][0] = a[0]。因为第一个节点不用跳就能得到。
代码:
#include <iostream>
#include <memory.h>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <queue>
#include <string>
#include <stack>
#include <iterator> using namespace std; typedef long long LL; const int MAXN = 1000 + 10; int dp[MAXN][MAXN];
int a[MAXN]; int main()
{
int t;
int n, l, r, k;
scanf("%d", &t);
while (t--)
{
memset(dp, 0, sizeof(dp));
scanf("%d%d%d%d", &n, &l, &r, &k);
for (int i = 1;i <= n;i++)
scanf("%d", &a[i]);
dp[1][0] = a[1];
for (int i = 1;i <= n;i++)
{
for (int j = i - r;j <= i - l;j++)
{
if (j < 1)
continue;
for (int m = 1;m <= k;m++)
dp[i][m] = max(dp[i][m], dp[j][m - 1] + a[i]);
}
}
int res = 0;
for (int i = 1;i <= n;i++)
for (int j = 1;j <= k;j++)
res = max(res, dp[i][j]);
printf("%d\n", res);
} return 0;
}
HDU-2182-Frog的更多相关文章
- HDU 5037 FROG (贪婪)
Problem Description Once upon a time, there is a little frog called Matt. One day, he came to a rive ...
- hdu 5037 Frog 贪心 dp
哎,注意细节啊,,,,,,,思维的严密性..... 11699193 2014-09-22 08:46:42 Accepted 5037 796MS 1864K 2204 B G++ czy Frog ...
- hdu 2128 Frog(简单DP)
Frog Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submi ...
- hdu 5037 Frog(贪心)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5037 题解:为了让放的石头有意义肯定是没l+1的距离放2个也就是说假设现在位置为pos那么 ...
- HDU 5037 Frog(贪心)
题意比较难懂,一只青蛙过河,它最多一次跳L米,现在河中有石头,距离不等,上帝可以往里加石头,青蛙非常聪明,它一定会选择跳的次数最少的路径.问怎么添加石头能让青蛙最多的次数.输出青蛙跳的最多的次数. 考 ...
- HDU 5037 Frog(2014年北京网络赛 F 贪心)
开始就觉得有思路,结果越敲越麻烦... 题意很简单,就是说一个青蛙从0点跳到m点,最多可以跳l的长度,原有石头n个(都仅表示一个点).但是可能跳不过去,所以你是上帝,可以随便在哪儿添加石头,你的策略 ...
- hdu 4004 The Frog's Games
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4004 The annual Games in frogs' kingdom started again ...
- HDU 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
随机推荐
- Python作业之用户管理
作业 流程图没有画,懒,不想画 readme没有写,懒,不想写.看注释吧233333 #! /usr/bin/env python # -*- coding: utf-8 -*- # __author ...
- 更改Windows的“视频”“图片”“”下载“文档”“音乐”“桌面”的默认路径
右键-->属性
- php排序方法之插入排序
//插入排序法 $arr = array(3,55,45,2,67,76,6.7,-65,85,4); function insertSort($arr){ for ( $i=0; $i<cou ...
- CentOS6.5 yum源设置
在安装完CentOS后一般需要修改yum源,才能够在安装更新rpm包时获得比较理想的速度. 国内比较快的有163源.sohu源.这里以163源为例子. 1. cd /etc/yum.repos.d 2 ...
- Opencv— — Bias and Gain
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- python 基础之第八天--字典相关
zx #####################创建字典###################################### In [11]: dict([('name','bob'),('a ...
- vue 路由监听
发现网上其实有很多种答案,但是测试之后发现很多都不行,或者写的不完整. 一.在app.vue组件内,增加监听$route,如下: watch: { $route(to, from) { console ...
- bzoj2330糖果——差分约束
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2330 差分约束,再建立一个源点0,向所有点连边权为1的边,表示每个人都会分到糖果: 答案较大 ...
- asp.net中FileUpload得到上传文件的完整路径
asp.net中FileUpload得到上传文件的完整路径 Response.Write("完整路径:" + Server.MapPath(FileUpload1.PostedFi ...
- html+css构成的框架,可自行改造
运行效果 代码下载地址:http://pan.baidu.com/s/1eSeBh2E