Jiudu OJ 1086 dynamic planning-"minimum cost"-questions about Tsinghua machine trial in 11 years

Source: Internet
Author: User

[Cpp] // 9 degrees OJ 1086 dynamic planning of the "minimum cost" // http://ac.jobdu.com/problem.php? Pid = 1086 # include <stdio. h> # define MAXN 2211686018427387904 # define MAXS 30000 long l1, l2, l3, c1, c2, c3, rout [MAXS]; long spe (int start, int end) // enter the start point and end point, and output the cost between the two sites. {Int temp = rout [end]-rout [start]; if (temp <= l1) return c1; if (temp <= l2) return c2; if (temp <= l3) return c3; return MAXN;} int main () {long temp, I, j, a, B, n, spend [MAXS]; while (~ Scanf ("% lld", & l1, & l2, & l3, & c1, & c2, & c3 )) {for (I = temp = 0; I <MAXS; I ++) rout [I] = spend [I] = MAXN; scanf ("% lld ", & a, & B); scanf ("% lld", & n); rout [1] = 0; for (I = 2; I <= n; I ++) scanf ("% lld", & rout [I]); for (I = a, spend [a] = 0; I <B; I ++) {for (j = I + 1; rout [j]-rout [I] <= l3 & j <MAXS; j ++) // ensure that the distance between the input two stations of the spe function is less than or equal to l3. {Temp = spe (I, j); if (spend [j]> spend [I] + temp) spend [j] = spend [I] + temp ;}} printf ("% lld \ n", spend [B]);} return 0 ;}

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.