标签:blog class code color int string
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 |
数塔问题<br>#include<iostream> #include<cstring> using
namespace std; int a[100009][12]; int maxi( int
a, int b, int c) { int
max1; max1=a>b?a:b; max1=max1>c?max1:c; return
max1; } int
main() { int
n,x,y; while (cin>>n) { if (n==0) break ; int
max=0; memset (a,0, sizeof (a)); for ( int
ii=0;ii<n;ii++) { scanf ( "%d%d" ,&x,&y); //cin>>x>>y; a[y][x]++; if (y>max) max=y; } for ( int
i=max-1;i>=0;i--) { if (a[i+1][0]>a[i+1][1]) a[i][0]+=a[i+1][0]; else a[i][0]+=a[i+1][1]; for ( int
j=1;j<=9;j++) a[i][j]+=maxi(a[i+1][j],a[i+1][j-1],a[i+1][j+1]); if (a[i+1][10]>a[i+1][9]) a[i][10]+=a[i+1][10]; else a[i][10]+=a[i+1][9]; } cout<<a[0][5]<<endl; } return
0; } |
标签:blog class code color int string
原文地址:http://www.cnblogs.com/zhangdashuai/p/3709751.html