1695 Windows 2013

Source: Internet
Author: User

1695 Windows

time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingView Run ResultsTitle Description Description

Adamyi's Windows 2013 timed out (--!), so he had to witness the movie scene in front of his own house. Although he did not want to miss this wonderful moment, his belly protested repeatedly and demanded that the Last supper be eaten first.

Now adamyi ready to eat N-dishes in turn. But he only use spoons and chopsticks to eat, spoons and chopsticks can be used alternately, but the same vegetables can only use a tableware, before dinner he took chopsticks. The time to eat the I course with a spoon and chopsticks is a_i and b_i respectively. The time for the chopsticks and the spoon to be exchanged is c_i before eating the I course.

Now tell Adamyi to finish the N-course meal according to his plan, the minimum time required.

Enter a description Input Description
First line, a positive integer n (1<=n<=100)
The following n rows, respectively, are three positive integers a_i,b_i,c_i (1<=a_i,b_i,c_i<=10000)
Output description Output Description

A number, the shortest time

Sample input Sample Input

3

20 40 20

10 4 25

90 100 5

Sample output Sample Output

139

Data range and Tips Data Size & Hint
PS: Let's say adamyi's belly is big enough to eat 100 dishes ...
Windows 2013:adamyi is written in a two-dimensional language system, because it is very unstable, so it only sells in two-dimensional.
Category labels Tags Click here to expandDynamic planning

Exercises

Water and Water backpack DP

AC Code:

#include <iostream>using namespacestd;Const intn= the;intn,a[n],b[n],c[n],f[n][2];intMain () {CIN>>N;  for(intI=1; i<=n;i++) cin>>a[i]>>b[i]>>C[i]; f[1][0]=b[1]; f[1][1]=c[1]+a[1];  for(intI=2; i<=n;i++) {f[i][0]=min (f[i-1][0]+b[i],f[i-1][1]+c[i]+B[i]); f[i][1]=min (f[i-1][0]+a[i]+c[i],f[i-1][1]+A[i]); } cout<<min (f[n][0],f[n][1]) <<Endl; return 0;}

1695 Windows 2013

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.