Topic link :https://vjudge.net/contest/126708#problem/F

The question : Seek the value and maximum value of the path from the top to the next , The problem came out in the competition But at that time, I couldn't understand the title and didn't write it , It's like a digital triangle , Just added the bottom part of him , It can be divided into two situations .

AC Code :

 #include<cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int i,j,n;
long long a[][],f[][],ans;
int main()
{
int t2;
scanf("%d",&t2);
for(int t1 = ; t1 <= t2; t1++)
{
scanf("%d",&n);
for(i = ; i <= *n-; i++)
for(j = ; j <= min(i,*n - i); j++)
{
scanf("%lld",&a[i][j]);
}
memset(f,,sizeof(f));
for(i = ; i <= *n-; i++)
for(j = ; j <= min(i,*n - i); j++)
{
if(i == ) f[i][j] = a[i][j];
if(i<=n)
{
f[i][j] = max(f[i-][j], f[i - ][j - ]) + a[i][j];
}
else
{
f[i][j] = max(f[i-][j], f[i - ][j + ]) + a[i][j];
}
}
printf("Case %d: %lld",t1,f[*n-][]);
putchar('\n'); }
return ;
}

2016huasacm Summer training five F - Monkey Banana Problem More articles about

  1. 2016huasacm Summer training five J - Max Sum

    Topic link :http://acm.hust.edu.cn/vjudge/contest/126708#problem/J The question : Find the continuous maximum sum of a paragraph , As long as each number is greater than 0 Then it will keep increasing , So just talk to 0 ...

  2. 2016huasacm Summer training three F - Jungle Roads

    Topic link :http://acm.hust.edu.cn/vjudge/contest/123674#problem/F The question : It's in communication n All the bridges on the island are broken , It's going to be rebuilt , It takes different time to rebuild each bridge , Ask to repair to make ...

  3. 2016huasacm Summer training five H - Coins

    Topic link :http://acm.hust.edu.cn/vjudge/contest/126708#problem/H The question :A There's a lot of coins , He thought it was too heavy , I want to spend money on a taxi : Taxi drivers can keep the change , but ...

  4. 2016huasacm Summer training five G - Qiuqiu series stories —— Lose weight I

    Topic link :http://acm.hust.edu.cn/vjudge/contest/126708#problem/G This is a 01 Template questions for backpacks AC Code : #include<stdio.h&g ...

  5. 2016huasacm Summer training five E - What Is Your Grade?

    Topic link :http://acm.hust.edu.cn/vjudge/contest/126708#problem/E The question : Give the number of questions made ,5 One of the 100 branch ,4 The first one n/2 Classmate 95, after n/2 Of 90 ...

  6. 2016huasacm Summer training five C-Common Subsequence

    Topic link :http://acm.hust.edu.cn/vjudge/contest/126708#problem/C The question : This is a problem of finding the maximum length of the common substring of a string , use dp The dynamic equation is just if(a[ ...

  7. 2016HUAS Summer training 2 F - A Simple Problem with Integers

    Description A sequence is given , You need to deal with the following two kinds of inquiries . "C a b c" Said to [a, b] All the values in the interval increase c (-10000 ≤ c ≤ 10000). " ...

  8. F - Monkey Banana Problem

    F - Monkey Banana Problem Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & ...

  9. 2016huasacm Summer training 4 DP_B

    Topic link :http://acm.hust.edu.cn/vjudge/contest/125308#problem/M The question : Yes N Items and a capacity for V The backpack . The first i The cost of each item is volume c[i], The value is w[ ...

Random recommendation

  1. The heavyweight came , Use CRL Realize the big data sub database and sub table scheme

    Detailed introduction to the scheme of sub database and sub table http://blog.csdn.net/bluishglc/article/details/7696085 I won't give a detailed description here The scheme of sub database and sub table cannot be separated from this structure , Subject to reality ...

  2. react Make a mistake

    1. import a from  './xx'   Be sure to have ./ 2. export default const x={} wrong Change it to  const x={}; export default x; also ...

  3. [webpack] devtool Configuration comparison

    File structure -src -views -essay -list.js -detail.js -index.js -webpack.config.js The contents of the document [/src/.../index.js] im ...

  4. Windows Key points of performance optimization -Windows Performance tuning important settings

    It's been reloaded recently windows8 System , I found that the performance was very poor , It's not as good as the official said win7 There's a lot to say . After several key configuration adjustments , Finally get back to the original style of the computer . So to summarize , Hopefully that helped : 1. Check windows service , ...

  5. JavaWeb technology ( 3、 ... and ):JDBC The core interface in

    One .  DriverManager Interface DriverManager Database connection driver interface , Used to get database connection objects Connection import java.sql.Connection; impor ...

  6. 2410 In interruption SRCPND and INTPND The question of clearing

    2410 In interruption SRCPND and INTPND The question of clearing SRCPND Is the interrupt source pin register , A bit is set 1 Indicates that the corresponding interrupt is triggered , But we know that the system can trigger several interrupts at the same time , As long as the interrupt is triggered ,SRCPND The corresponding bit of ...

  7. HDU 4605 Magic Ball Game ( Online chairman tree || offline Line segment tree )

    Reprint please indicate the source , thank you http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove The question : Give me a binary tree , The number of children per node is 0 perhaps 2. ...

  8. VBA Developing learning -- Basic grammar 3

    VBA List of string functions Trim(string) Get rid of string Left and right margins Ltrim(string) Get rid of string Left margin Rtrim(string) Get rid of string Blank on the right Len(str ...

  9. How to use Google APIs and Google Application system integration (7)---- On the inside JSON exchange XML Data processing ,JSON The data includes violations XML Data specifications :XML Node name does not support number Java Explain

    I call Google Calendar APIs Of GetColors Method , among ( For more information Google Calendar API already Google API See the rest of my blog post , at present , We only take Go ...

  10. python take PNG Format of the picture into jpg

    """ Let's talk about it first jpg Pictures and png The difference between pictures jpg Format : Is a lossy image compression type , Better image quality with minimum disk space png Format : It's not compressibility , It can save transparent pictures " ...