怒刷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,的数值要特别赋值. ...
随机推荐
- redis 重用命令
一. set 1.smembers key 查看所有元素
- lua安装和简单使用
1.安装 下载地址:https://www.lua.org/download.html 编译之前要安装readline,直接用yum安装 yum -y install readline-devel n ...
- 特现C语言编程特点的小代码,itoa,数值转换成字符串
#define BASE_MAX (26 + 10) char const* itostr(int x, int base) { /* map 居中, 支技负余数 */ static char con ...
- [SQL]sql语句bug
sql语句格式必须严格检查,一个空格的错误都会导致执行错误. 常见有 1:字符串的值要用 ‘ ’ 括起来 2:用 , 分隔语句段 3:切记判断条件前有一空格:eg:这里最容易出错 4:属性名是否 ...
- 利用HTML5开发Android(6)---构建HTML5离线应用
需要提供一个cache manifest文件,理出所有需要在离线状态下使用的资源例如 Manifest代码 CACHE MANIFEST #这是注释 images/sound-icon.png ima ...
- C#中的Collection 2
Core Generic interface IEnumerable<T>:you can interate my elemnts, no need to know the count, ...
- MFC非模态对话框中屏蔽ESC键
个人的编程经验认为:对于非模态对话框,按下ESC键和点击红叉都会响应OnCancel()函数,而不会去响应OnClose()函数. 我们都知道,如果想屏蔽Enter键,只须重写OnOK()函数即可(重 ...
- IIS网站程序无法访问oracle
系统环境: win7 + iis7 asp.net应用程序访问oracle数据库时,报ORA-12560: TNS: 协议适配器错误. 使用c/s程序访问数据库没有问题,plsql也没问题,说明ora ...
- UVa11205 The Broken Pedometer
// 题意:有P个LED灯,以及N个字符,要求选出个数最少的LED灯,使得即使只有这些灯正常工作,也能区分出这N个字符 // 题意抽象:输入两个整数P, N以及N行P列的01矩阵,找少的列,能区分所有 ...
- js密码强度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...