标签:des style http color java os strong io
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13077 Accepted Submission(s): 4328
借鉴别人的代码:
#include<stdio.h>
#include<string.h>
#define M 100001
int
n;
int
x;
//位置
int
T;
//时间
int
time
;
int
number[M][13];
int
max2(
int
a,
int
b)
{
if
(a>b)
return
a;
return
b;
}
int
max3(
int
a,
int
b,
int
c)
{
if
(max2(a,b)>max2(b,c))
return
max2(a,b);
return
max2(b,c);
}
int
main()
{
while
(
scanf
(
"%d"
, &n)==1 && n)
{
memset
(number, 0,
sizeof
(number));
//初始化数组
time
= 0;
while
(n--){
scanf
(
"%d %d"
, &x, &T);
//读取数据
number[T][x + 1]++;
//时间做数塔纵轴,位置+1做数塔横轴,问题转化为经典数塔问题
if
(T >
time
)
//确定最大时间
time
= T;
}
for
(
int
i =
time
- 1; i >= 0; i--){
for
(
int
j = 11; j >=1; j--) {
number[i][j] += max3(number[i+1][j],number[i+1][j-1],number[i+1][j+1]);
//对熟悉的数塔问题进行操作,注意下面的三个位置都能操作
}
}
printf
(
"%d\n"
, number[0][6]);
//输出结果
}
return
0;
}
hdoj 1176(可转化为数塔),布布扣,bubuko.com
标签:des style http color java os strong io
原文地址:http://www.cnblogs.com/weiyikang/p/3881195.html