hdu 1176 免费馅饼
来源:互联网 发布:中国工业总产值数据 编辑:程序博客网 时间:2024/04/29 21:50
拉拉拉拉拉拉~~~~~~~dp水水~~~~~~~~~~~~
好不容易AC之后,看status,发现这题被zzuli的小盆友们集体虐过,ORZ。。。
这题开始想得有问题,没考虑中间间隔时间大的话肿么样。今晚想了想,改成按时间DP,因为当前时间的状态只和上一秒状态有关。
所以直接用上一秒相邻两个以及自己(忘了这个,WA了几次)状态更新即可。当然,开始的时候需要存下馅饼的时间,地点,如果5可以到达的话,那么更新的时候加上去即可。
虽然很水,但是还是蛮开心的~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <queue>#include <stack>#include <math.h>#include <time.h>#include <stdio.h>#include <stdlib.h>#include <iostream>#include <limits.h>#include <string.h>#include <string>#include <algorithm>#define MID(x,y) ( ( x + y ) >> 1 )#define L(x) ( x << 1 )#define R(x) ( x << 1 | 1 )#define BUG puts("here!!!")using namespace std;const int MAX = 100010;const int MAX_N = 15;int dp[MAX_N][MAX];int tt[MAX_N][MAX];int main(){int n,x,t;while( ~scanf("%d",&n) && n ){memset(dp, 0, sizeof(dp));memset(tt, 0, sizeof(tt));int max_t = 0;for(int i=0; i<n; i++){scanf("%d%d",&x,&t);max_t = max(max_t, t);tt[x][t]++;}int ans = 0;for(int i=1; i<=max_t; i++)for(int k=0; k<=10; k++){int t = dp[k][i-1];if( k >= 1 ) t = max(t, dp[k-1][i-1]);if( k <= 9 ) t = max(t, dp[k+1][i-1]);dp[k][i] = t;if( tt[k][i] && i >= abs(k-5) )dp[k][i] += tt[k][i];ans = max(ans, dp[k][i]);}printf("%d\n",ans);}return 0;}
- hdu 1176 免费馅饼
- hdu 1176 免费馅饼
- hdu 1176 免费馅饼
- HDU 1176 - 免费馅饼
- hdu 1176 免费馅饼
- hdu 1176免费馅饼
- hdu 1176 免费馅饼
- HDU 1176 免费馅饼
- hdu 1176 免费馅饼
- HDU 1176 免费馅饼
- hdu 1176 免费馅饼
- hdu - 1176 - 免费馅饼
- HDU 1176 免费馅饼
- HDU 1176 免费馅饼
- hdu 1176 免费馅饼
- HDU 1176 免费馅饼
- 免费馅饼 hdu 1176
- hdu 1176 免费馅饼
- 植物大战僵尸JavaSE版
- 基于Video4Linux 的USB摄像头图像采集实现
- Linux下S3C2440 RTC实时时钟驱动配置与修改
- Failed to create the Java Virtual Machine||不知道为什么。。。大神们能告诉我吗?
- 四道面试题
- hdu 1176 免费馅饼
- S3C2440 UART2被配置为CTS问题解决
- centos BCM4312 802.11b/g无线网卡驱动安装
- 位域
- 电容的作用?电容器的作用?
- 测试一下
- JMS与Spring之二(用message listener container异步收发消息)
- C++虚函数表解析
- 使用DLL封装应用程序的资源