HDU1176
来源:互联网 发布:mac专柜价多少 编辑:程序博客网 时间:2024/05/24 01:07
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1176
package DP;import java.util.*;public class HDU1176 {// arr[i][j]表示第i秒第j个位置的馅饼的数目。static int[][] arr;public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n;while (sc.hasNext()) {arr = new int[100001][11];n = sc.nextInt();if (n == 0)break;int maxt = 0;// 最大时间。while (n-- > 0) {int x = sc.nextInt();int t = sc.nextInt();arr[t][x]++;if (t > maxt)maxt = t;}for (int i = maxt - 1; i >= 0; i--) {for (int j = 1; j <= 9; j++) {arr[i][j] += getMax(arr[i + 1][j - 1], arr[i + 1][j], arr[i + 1][j + 1]);}arr[i][0] += Math.max(arr[i + 1][0], arr[i + 1][1]);arr[i][10] += Math.max(arr[i + 1][10], arr[i + 1][9]);}System.out.println(arr[0][5]);}}private static int getMax(int a, int b, int c) {int max1;max1 = a > b ? a : b;max1 = max1 > c ? max1 : c;return max1;}}
- hdu1176
- HDU1176
- HDU1176
- hdu1176
- hdu1176
- hdu1176
- HDU1176
- hdu1176
- HDU1176(DP)
- hdu1176(dp)
- hdu1176 dp
- hdu1176(DP)
- HDU1176 DP
- HDU1176免费馅饼
- HDU1176 免费馅饼
- hdu1176免费馅饼
- HDU1176 数塔DP
- HDU1176 免费馅饼
- HDU2084
- Android之TextView属性列表
- oracle用户类型区别
- issue in Emacs24
- 关于cocos2d中InstallWizardForVS2010.js文件安装问题
- HDU1176
- 操作符重载
- Java中带复选框的树(Java CheckBox Tree)的实现和应用
- 树的子结构
- 实现按日期和大小排序 Android
- SVN下载代码
- 嫣然一笑苦了情
- HDU2151
- 【java】构造函数的继承执行顺序