当前位置:网站首页>G - Cow Bowling
G - Cow Bowling
2022-06-26 12:40: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;
}
边栏推荐
- RSS rendering of solo blog system failed
- P2393 yyy loves Maths II
- processsing 函数random
- PostGIS calculation angle
- File remote synchronization and backup artifact Rsync
- 不到40行代码手撸一个BlocProvider
- Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor
- Redis learning - 06 drifting bottle case
- Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis
- postgis计算角度
猜你喜欢

文件远程同步、备份神器rsync

Tiger DAO VC产品正式上线,Seektiger生态的有力补充
![[esp32-c3][rt-thread] run RT-Thread BSP minimum system based on esp32c3](/img/4a/503240b332e3279047c438f1d9845e.png)
[esp32-c3][rt-thread] run RT-Thread BSP minimum system based on esp32c3

Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor

自动化测试的局限性你知道吗?

System tasks (display / print class) in Verilog - $display, $write, $strobe, $monitor

倍福CX5130换卡对已有的授权文件转移操作

Research and development practice of Kwai real-time data warehouse support system

软件测试 - 概念篇

机器学习笔记 - 时间序列的季节性
随机推荐
倍福NC轴状态转移图解析
机组实践实验8——使用CMStudio设计基于基本模型机微程序指令(1)
自动化测试的局限性你知道吗?
Lightflow completed the compatibility certification with "daocloud Enterprise Cloud native application cloud platform"
HDU 3709 Balanced Number
倍福通过CTU和TON实现时间片大小和数量的控制
国标GB28181协议EasyGBS级联宇视平台,保活消息出现403该如何处理?
源码学习:AtomicInteger类代码内部逻辑
C structure: definition and example
Typescript
How does easygbs solve the abnormal use of intercom function?
P2393 yyy loves Maths II
自定义封装下拉组件
Openlayers drawing dynamic migration lines and curves
Photoshop 2022 23.4.1增加了哪些功能?有知道的吗
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
The El form item contains two inputs. Verify the two inputs
postgis計算角度
A must for programmers, an artifact utools that can improve your work efficiency n times
Software testing - concept