Hdu 2059 simple and Dynamic Planning

Source: Internet
Author: User

This topic needs to be taken into consideration from the whole. For the charging station and the terminal point N + 1, the shortest time to reach them must be directly reached after the power is finished at a certain point in front of them. Using t [I] to record the shortest distance to point I, t [I] is from 0 --> (I-1) the minimum value of the time when these vertices are fully charged. [Cpp] # include <stdio. h> int L, N, C, T, Vr, Vt1, Vt2, q [111]; double t [111]; void time () {int I, j; double min, tim; for (I = 1; I <= N + 1; I ++) {if (C> = q [I]) min = 1.0 * q [I]/Vt1; else min = 1.0 * C/Vt1 + 1.0 * (q [I]-C)/Vt2; for (j = 1; j <I; j ++) {if (C> = q [I]-q [j]) tim = 1.0 * (q [I]-q [j]) /Vt1 + 1.0 * t [j] + 1.0 * T; else tim = 1.0 * C/Vt1 + 1.0 * (q [I]-q [j]-C) /Vt2 + 1.0 * t [j] + 1.0 * T; if (tim <min) min = tim;} t [I] = min ;}} int main () {int k; double Tr, Tt; While (scanf ("% d", & L )! = EOF) {scanf ("% d", & N, & C, & T, & Vr, & Vt1, & Vt2 ); for (k = 1; k <= N; k ++) {scanf ("% d", & q [k]);} q [N + 1] = L; time (); Tr = 1.0 * L/Vr; Tt = t [N + 1]; if (Tr <Tt) printf ("Good job, rabbit! \ N "); else printf (" What a pity rabbit! \ N ") ;}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.