怒刷DP之 HDU 1176
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
prayerhgq (2015-07-28)
System Crawler (2015-09-05)
Description
为了使问题简化,假设在接下来的一段时间里,馅饼都掉落在0-10这11个位置。开始时gameboy站在5这个位置,因此在第一秒,他只能接到4,5,6这三个位置中其中一个位置上的馅饼。问gameboy最多可能接到多少个馅饼?(假设他的背包可以容纳无穷多个馅饼)
Input
Output
提示:本题的输入数据量比较大,建议用scanf读入,用cin可能会超时。
Sample Input
5 1
4 1
6 1
7 2
7 2
8 3
0
Sample Output
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <climits>
using namespace std; const int SIZE = ;
int DP[SIZE][];
struct Node
{
int pos,time;
}S[SIZE]; bool comp(const Node & r_1,const Node & r_2);
int main(void)
{
int n; while(scanf("%d",&n) && n)
{
memset(DP,,sizeof(DP));
for(int i = ;i < n;i ++)
scanf("%d%d",&S[i].pos,&S[i].time);
sort(S,S + n,comp); int ans = ;
for(int i = ;i < n;i ++)
{
int box = ;
if(S[i].time < abs(S[i].pos - ))
continue;
for(int j = ;j <= ;j ++)
for(int t = S[i].time - abs(S[i].pos - j);t >= ;t --)
if(DP[t][j])
{
box = max(box,DP[t][j]);
break;
}
DP[S[i].time][S[i].pos] = box + ;
ans = max(ans,box + );
}
printf("%d\n",ans);
} return ;
} bool comp(const Node & r_1,const Node & r_2)
{
return r_1.time < r_2.time;
}
怒刷DP之 HDU 1176的更多相关文章
- 怒刷DP之 HDU 1257
最少拦截系统 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 怒刷DP之 HDU 1160
FatMouse's Speed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Su ...
- 怒刷DP之 HDU 1260
Tickets Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- 怒刷DP之 HDU 1087
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- 怒刷DP之 HDU 1114
Piggy-Bank Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit S ...
- 怒刷DP之 HDU 1069
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- 怒刷DP之 HDU 1024
Max Sum Plus Plus Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- 怒刷DP之 HDU 1029
Ignatius and the Princess IV Time Limit:1000MS Memory Limit:32767KB 64bit IO Format:%I64d &a ...
- 【DP】HDU 1176
HDU 1176 免费馅饼 题意:中文题目不解释. 思路:因为是从中间出发所以思路卡了许久,还在之前做了道HIHO入门的题.能想到的点,从时间思考,然后初始化1s的时候,4,5,6,的数值要特别赋值. ...
随机推荐
- mvc4帮助类
@App @AppState @Ajax @Cache @Context @Culture @Html @IsPost @Layout @Model @Output @OutputStack @Pag ...
- How to use SourceGear DiffMerge in SourceSafe, TFS, and SVN【项目】
What is DiffMerge DiffMerge is yet-another-diff-and-merge-tool from the fine folks at SourceGear. I ...
- 【转】BitmapFactory.Options
BitmapFactory.Options这个类的信息:http://developer.android.com/reference/android/graphics/BitmapFactory.Op ...
- 面向过程MySQL数据库链接操作
刚好今天复习到这个章节,将就发布出来,就当是为自己复习了 //链接数据库 $link = mysqli_connect('localhost/IP地址','用户名','密码','数据库名'); //设 ...
- Generate the Jobs script from msdb Database
前两周,由于数据库简繁体的转换,大量的数据库需要转到新的服务器. 在转其中的一台的时候,原先导出来的JOBS脚本不翼而飞(原因至今未明),而恰巧这一台服务器有90多个JOB(看下图恢复后的,注意滚动条 ...
- cdoj 1131 男神的礼物 区间dp
男神的礼物 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/1131 Descr ...
- 使用foreach碰到的问题
foreach($list as $k=>$v ){ ........... } 和下面: foreach($list as &$v){ ........ } 其实两者的结果是一样的,但 ...
- 《MySQL必知必会》读书笔记
一.了解MySQL 1.什么是数据库? 数据库是一种以某种有组织的方式存储的数据集合. 2.模式(schema):关于数据库和表的布局及特性的信息. 3. ...
- iOS开发——UI篇Swift篇&玩转UItableView(一)基本使用
UItableView基本使用 class ListViewController: UIViewController , UITableViewDataSource, UITableViewDeleg ...
- NHibernate从入门到精通系列
http://www.cnblogs.com/GoodHelper/archive/2011/02/17/1948744.html NHibernate从入门到精通系列(4)——持久对象的生命周期(上 ...