USACO 2008 Running(贝茜的晨练)


【题解】
动态规划,dp[i][j]表示第i分钟疲劳度为j的最长距离。
【代码】
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;
#define scan(x) cin >> x
#define print(x) printf("%d\n", x)
#define maxn 10005
#define maxm 505 int D[maxn], dp[maxn][maxm]; int main()
{
int N, M;
scan(N);
scan(M);
for (int i = ; i <= N; i++) scan(D[i]);
for (int i = ; i <= N; i++) {
dp[i][] = dp[i - ][];
for (int j = ; j <= i && j <= M; j++) {
dp[i][] = max(dp[i][], dp[i - j][j]); // If spent the preceding j minutes resting
dp[i][j] = max(dp[i][j], dp[i - ][j - ] + D[i]); // Run when fatigue degree is j.
}
}
print(dp[N][]);
//system("pause");
return ;
}
USACO 2008 Running(贝茜的晨练)的更多相关文章
- BZOJ1613: [Usaco2007 Jan]Running贝茜的晨练计划
1613: [Usaco2007 Jan]Running贝茜的晨练计划 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1138 Solved: 554[ ...
- BZOJ 1613: [Usaco2007 Jan]Running贝茜的晨练计划( dp)
dp乱搞即可...( 我就是这样 A 的.. 后来想改快一点..然后就WA了...不理了 ------------------------------------------------------- ...
- BZOJ 1613: [Usaco2007 Jan]Running贝茜的晨练计划
题目 1613: [Usaco2007 Jan]Running贝茜的晨练计划 Time Limit: 5 Sec Memory Limit: 64 MB Description 奶牛们打算通过锻炼来 ...
- 1613: [Usaco2007 Jan]Running贝茜的晨练计划
1613: [Usaco2007 Jan]Running贝茜的晨练计划 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1252 Solved: 609 ...
- [bzoj1613][Usaco2008 Jan]Running贝茜的晨练计划_动态规划
Running贝茜的晨练计划 bzoj-1613 Usaco-2008 Jan 题目大意:题目链接(U组题题意真的是没法概括qwq....). 注释:略. 想法:一眼dp题. 状态:dp[i][j]表 ...
- [Usaco2007 Jan]Running贝茜的晨练计划[一般DP]
Description 奶牛们打算通过锻炼来培养自己的运动细胞,作为其中的一员,贝茜选择的运动方式是每天进行N(1 <= N <= 10,000)分钟的晨跑.在每分钟的开始,贝茜会选择下一 ...
- 【BZOJ】1613: [Usaco2007 Jan]Running贝茜的晨练计划(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1613 水题dp 设d[i][j]为i分钟疲劳为j d[i][j]=d[i-1][j-1]+a[i] ...
- 【dp】bzoj1613: [Usaco2008 Jan]Running贝茜的晨练计划
还记得这是以前看上去的不可做题…… Description 奶牛们打算通过锻炼来培养自己的运动细胞,作为其中的一员,贝茜选择的运动方式是每天进行N(1<=N<=10,000)分钟的晨跑.在 ...
- 【动态规划】bzoj1613 [Usaco2007 Jan]Running贝茜的晨练计划
#include<cstdio> #include<algorithm> using namespace std; #define N 10001 int n,m,a[N],f ...
随机推荐
- Creating Node.js Command Line Utilities to Improve Your Workflow
转自:https://developer.telerik.com/featured/creating-node-js-command-line-utilities-improve-workflow/ ...
- 几个方便进行micro frontend 开发的工具&&类库
nodejs 类库 从当前来说nodejs 的npm 偏多,因为毕竟面向的是web 编程 tailor 一个layout 服务(基于fragment 的开发方式)https://github.com/ ...
- auto_ptr & share_ptr & unique_ptr
Using auto_ptr, you don’t need think about the memory deallocation, but there are also many argument ...
- 99乘法表的正反写 (python的写法)
# 正写 j = 0 k = 0 while j < 10: j+=1 while k <10: k+=1 if j>k: k = 0 break else: print('{}*{ ...
- JVM 新生代与老年代
JVM中的堆可分为新生代与老年代 新生代 新生代主要是用来存放新生的对象.一般占据堆的1/3空间.由于频繁创建对象,所以新生代会频繁触发MinorGC进行垃圾回收. 新生代又分为 Eden区.Serv ...
- Spring IOC(一)概览
Spring ioc源码解析这一系列文章会比较枯燥,但是只要坚持下去,总会有收获,一回生二回熟,没有第一次,哪有下一次... 本系列目录: Spring IOC(一)概览 Spring IOC(二)容 ...
- 阿里云 CentOS安装Git
一.Git的安装 1. 下载Git wget https://github.com/git/git/archive/v2.8.0.tar.gz 2. 安装依赖 sudo yum -y install ...
- win7重装系统笔记
制作U盘启动盘:链接 原文链接:链接 开机进入bios界面(华硕:F2) 按方向左右键进入:Boot选项,将“Lunch CSM”设置为“Enabled” 方向键选择“Security”,将“Secu ...
- elasticsearch 基本操作
安装delete_by_query ,cd进/bin,执行./plugin install delete-by-query DELETE http://192.168.1.12:9200/dd ...
- 小米笔记本装MAC(黑苹果),外接USB蓝牙,禁止笔记本自带的蓝牙方法
https://blog.daliansky.net/ 解决插入耳机没有声音问题,每次开机需要重新插拔一次:https://github.com/daliansky/XiaoMi-Pro/blob/m ...