当前位置:网站首页>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;
}
边栏推荐
- Stream learning record
- Power Designer - Custom Comment button
- Enjoy element mode (flyweight)
- 倍福EtherCAT Xml描述文件更新和下载
- Electron official docs series: Testing And Debugging
- Common creation and usage of singletons
- Electron official docs series: Best Practices
- 详细讲解C语言11(C语言系列)
- Opencv high speed download
- scrapy——爬取漫画自定义存储路径下载到本地
猜你喜欢

scrapy——爬取漫画自定义存储路径下载到本地
![Vivado error code [drc pdcn-2721] resolution](/img/de/ce1a72f072254ae227fdcb307641a2.png)
Vivado error code [drc pdcn-2721] resolution

This function has none of deterministic, no SQL solution
![Vivado 错误代码 [DRC PDCN-2721] 解决](/img/de/ce1a72f072254ae227fdcb307641a2.png)
Vivado 错误代码 [DRC PDCN-2721] 解决

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

Word document export (using fixed template)

详细讲解C语言11(C语言系列)

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

倍福TwinCAT3实现CSV、TXT文件读写操作
微信小程序测试点总结
随机推荐
Learning Processing Zoog
倍福TwinCAT通过Emergency Scan快速检测物理连接和EtherCAT网络
processsing 函数random
Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis
sql 将数据表b字段值赋值到数据表a中某一列
5月产品升级观察站
橋接模式(Bridge)
倍福EtherCAT Xml描述文件更新和下载
[geek challenge 2019] rce me 1
倍福TwinCAT3实现CSV、TXT文件读写操作
【网络是怎么连接的】第二章(中):一个网络包的发出
OPLG: 新一代云原生可观测最佳实践
四类线性相位 FIR滤波器设计 —— MATLAB源码全集
Common creation and usage of singletons
Unit practice experiment 8 - using cmstudio to design microprogram instructions based on basic model machine (1)
code force Party Lemonade
UVa11582 [快速幂]Colossal Fibonacci Numbers!
Dark horse notes - Common APIs
单例的常用创建和使用方式
C语言:练习题二