当前位置:网站首页>G - Cow Bowling
G - Cow Bowling
2022-06-26 13:09:00 【YJEthan】
Description
7 3 8 8 1 0 2 7 4 4 4 5 2 6 5Then the other cows traverse the triangle starting from its tip and moving "down" to one of the two diagonally adjacent cows until the "bottom" row is reached. The cow's score is the sum of the numbers of the cows visited along the way. The cow with the highest score wins that frame.
Given a triangle with N (1 <= N <= 350) rows, determine the highest possible sum achievable.
Input
Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.
Output
Sample Input
5 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5
Sample Output
30
Hint
7
*
3 8
*
8 1 0
*
2 7 4 4
*
4 5 2 6 5 The highest score is achievable by traversing the cows as shown above #include<stdio.h>
int main()
{
int i,j,n;
int a[360][360],max[361][361];
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=1;i<=n;i++)
{
max[n][i]=a[n][i];
}
for(i=n-1;i>0;i--)
{
for(j=1;j<=i;j++)
{
a[i][j]+=a[i+1][j]>a[i+1][j+1]?a[i+1][j]:a[i+1][j+1];
}
}
printf("%d\n",a[1][1]);
}return 0;
}
边栏推荐
- HDU 5860
- Source code learning: atomicinteger class code internal logic
- 解中小企业之困,百度智能云打个样
- P5733 [deep foundation 6. example 1] automatic correction
- PostGIS geographic function
- Goto statement to realize shutdown applet
- 自定义封装下拉组件
- National standard gb28181 protocol easygbs cascaded universal vision platform, how to deal with live message 403?
- 倍福TwinCAT3实现CSV、TXT文件读写操作
- This function has none of deterministic, no SQL solution
猜你喜欢

P2393 yyy loves Maths II
微信小程序测试点总结
Summary of wechat applet test points

Group counting practice experiment 9 -- using cmstudio to design microprogram instructions based on segment model machine (2)

C# const详解:C#常量的定义和使用

IDC报告:百度智能云AI Cloud市场份额连续六次第一

Unit practice experiment 8 - using cmstudio to design microprogram instructions based on basic model machine (1)

MariaDB study notes

scrapy——爬取漫画自定义存储路径下载到本地

Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control
随机推荐
Script - crawl the customized storage path of the cartoon and download it to the local
橋接模式(Bridge)
Adobe Acrobat prevents 30 security software from viewing PDF files or there are security risks
Lightflow completed the compatibility certification with "daocloud Enterprise Cloud native application cloud platform"
心脏滴血漏洞(CVE-2014-0160)分析与防护
First knowledge - Software Testing
Photoshop 2022 23.4.1增加了哪些功能?有知道的吗
Electron official docs series: Distribution
Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S
Electron official docs series: Best Practices
Bridge mode
【网络是怎么连接的】第二章(中):一个网络包的发出
Detailed explanation of C const: definition and use of C constant
National standard gb28181 protocol easygbs video platform TCP active mode streaming exception repair
P5733 [deep foundation 6. example 1] automatic correction
详细讲解C语言11(C语言系列)
10秒内完成火灾预警,百度智能云助力昆明官渡打造智慧城市新标杆
Openlayers drawing dynamic migration lines and curves
Goto statement to realize shutdown applet
Enjoy element mode (flyweight)