暑期dp46道(33)--HDOJ 1176 免费馅饼 类树塔:
来源:互联网 发布:higher brothers 知乎 编辑:程序博客网 时间:2024/05/22 03:46
题目链接:HDOJ 1176
树塔问题,data[i][j]表示i时刻,j+1位置能接到最大馅饼数;
代码:
#include<cstdio>#include<cstring>#include<string>#define debug 0#define M(a) memset(a,0,sizeof(a))#define Max(a,b) ((a>b)?a:b)const int maxn = 100000 + 5;int data[maxn][15];int n, total;void Do(){for (int i = total - 1; i >= 0; i--){for (int j = 1; j <= 11; j++)data[i][j] += Max(data[i + 1][j], Max(data[i + 1][j - 1], data[i + 1][j + 1]));}printf("%d\n", data[0][6]);}int main(){#if debugfreopen("in.txt", "r", stdin);#endif//debugint pos, time;while (~scanf("%d", &n) && n){total = 0;M(data);for (int i = 1; i <= n; i++){scanf("%d%d", &pos, &time);total = Max(total, time);//printf("%d\n",total);data[time][pos + 1]++;}Do();}return 0;}
1 0
- 暑期dp46道(33)--HDOJ 1176 免费馅饼 类树塔:
- 暑期dp46道(27)--HDOJ 3008 Warcraft
- 暑期dp46道(36)--HDOJ 2577
- 暑期dp46道(37) HDOJ 2844 COINS
- 暑期dp46道(44)--HDOJ 1058
- 暑期dp46道(46)--HDOJ 1069
- hdoj 1176 免费馅饼
- hdoj 1176 免费馅饼
- HDOJ 1176 免费馅饼
- HDoj-1176-免费馅饼
- HDOJ 1176 免费馅饼
- hdoj(1176 免费馅饼
- HDOJ-----1176免费馅饼
- HDOJ 1176 免费馅饼
- hdoj 1176 免费馅饼
- hdu/hdoj 1176-免费馅饼
- hdoj.1176 免费馅饼 20141030
- hdoj 1176免费馅饼【dp】
- 测试问题
- 24. Swap Nodes in Pairs
- tjut 2890
- Android布局学习(一)——TableLayout
- 移植uboot第六步:支持NANDFlash
- 暑期dp46道(33)--HDOJ 1176 免费馅饼 类树塔:
- Github上Stars最多的53个深度学习项目,TensorFlow遥遥领先
- OD IDA 找到延迟代码,编码实现加速
- quartz定时任务
- Particle for alexa smart home skill (2)
- POJ1416-Shredding Company
- __builtin_expect(!!(x), 1) 之__builtin_expect
- 二叉树排序
- Back Top ①(回到顶部)原生JS实现