Peking University teaches you how to play bowling
The topic is very simple, I do not translate, simply means to store the total number of each row, similar to the state compression
1#include <stdio.h>2#include <stdlib.h>3 #defineMAX (A, b) a>b?a:b4 5 intcow_map[351][351];6 7 voidSearch (Const int);8 9 intMainvoid)Ten { One intN, I, line; A while(~SCANF ("%d", &N)) - { -cow_map[0][0] =0; the for(line =1; Line <= N; line++)//Read Graph - for(i =0; I < line; i++) -scanf"%d", &cow_map[line][i]); - Search (N); + } - return 0; + } A at voidSearch (Const intN) - { - intLine, I, ans =0; - for(line =2; Line <= N; line++) - { -cow_map[line][0] = cow_map[line][0] + Cow_map[line-1][0]; in for(i =1; I < line-1; i++) -Cow_map[line][i] = (MAX (Cow_map[line-1][i-1], Cow_map[line-1][i]) +Cow_map[line][i]; toCow_map[line][line-1] = Cow_map[line][line-1] + Cow_map[line-1][line-2]; + } - for(i =0; i < N; i++) theAns =MAX (Cow_map[n][i], ans); *printf"%d\n", ans); $}
Dp:cow Bowling (3176)