hdu1176 免费馅饼
来源:互联网 发布:动漫人设用什么软件 编辑:程序博客网 时间:2024/05/16 07:24
题意:
在一条线上一个人最初在5点,美妙只能向两边移动一个位置,给你每个时间段掉馅饼的个数,问最后可以接到多少个馅饼。
一个变形的数塔问题,最上面是一个顶点,每个时间是一层转移。
#include <fstream>#include <iostream>#include <string>#include <complex>#include <math.h>#include <set>#include <vector>#include <map>#include <queue>#include <stdio.h>#include <stack>#include <algorithm>#include <list>#include <ctime>#include <memory.h>#include <ctime>#include <assert.h>#define rep(i,a,n) for (int i=a;i<n;i++)#define per(i,a,n) for (int i=n-1;i>=a;i--)#define pb push_back#define mp make_pair#define all(x) (x).begin(),(x).end()#define fi first#define se second#define eps 1e-8#define M_PI 3.141592653589793typedef long long ll;const ll mod=1000000007;const int inf=99999999;ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}using namespace std;int dp[100000+10][15],M[100000+10][15];int main(){ int n; while(~scanf("%d",&n)&&n) { int T=0; memset(dp,0,sizeof(dp)); memset(M,0,sizeof(M)); for(int i=0;i<n;i++) { int a,b;scanf("%d%d",&a,&b); M[b][a]++; T=max(T,b); } //cout<<"T="<<T<<endl; for(int i=1;i<=11;i++) dp[T][i]=M[T][i]; for(int i=T-1;i>=0;i--) { for(int j=1;j<=11;j++) { dp[i][j]=max(dp[i+1][j+1],max(dp[i+1][j-1],dp[i+1][j]))+M[i][j]; } } printf("%d\n",dp[0][6]); }}
0 0
- HDU1176免费馅饼
- HDU1176 免费馅饼
- hdu1176免费馅饼
- HDU1176 免费馅饼
- hdu1176免费馅饼
- hdu1176 免费馅饼
- HDU1176--免费馅饼
- hdu1176-免费馅饼
- hdu1176 免费馅饼
- HDU1176 免费馅饼
- hdu1176 免费馅饼
- hdu1176 免费馅饼
- hdu1176免费馅饼 dp
- HDU1176:免费馅饼(DP)
- HDU1176 免费馅饼
- hdu1176---免费馅饼
- HDU1176免费馅饼
- hdu1176免费馅饼(DP)
- HTML兼容性问题
- Android实战 - 音心播放器 (Music Service 实现)
- 实战c++中的vector系列--copy set to vector(别混淆了reserve和resize)
- LR11录制回放出现中文乱码以及录制时一直跳到360浏览器的解决方法
- 常见错误8-搭建hexo,本地server成功,部署到github上之后不能显示主题样式
- hdu1176 免费馅饼
- Ant(GG)
- 因为PPBC的防盗链,尝试用vba的对象来解决,顺便复习一下。。。
- NGUI 背包暂时完成
- 对于nginx一些配置的建议值
- 分治:区间和问题
- ZOJ 1045 HangOver
- 区间选点问题(贪心)
- MAC 上 mysql 的编码设置