[DP Special]HDU 1260 TICKETS

Source: Internet
Author: User
Tags integer numbers

Tickets

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 1408 Accepted Submission (s): 687


Problem Descriptionjesus, what a great movie! Thousands of people is rushing to the cinema. However, the really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as possible.
A good approach, reducing the total time of tickets selling, are let adjacent people buy tickets together. As the restriction of the Ticket Seller machine, Joe can sell a single Ticket or both adjacent tickets at a time.
Since you is the great JESUS, you know exactly what much time needed for every person to buy a single ticket or both ticket s for him/her. Could kind to tell poor Joe at what time Could he go home as early as possible? If So, I guess Joe would full of appreciation for your help.

Inputthere is N (1<=n<=10) different scenarios, each scenario consists of 3 lines:
1) An integer K (1<=k<=2000) representing the total number of people;
2) K integer Numbers (0s<=si<=25s) representing the time consumed to buy a ticket for each person;
3) (K-1) integer numbers (0s<=di<=50s) representing the time needed for both adjacent people to buy the tickets Togeth Er.

Outputfor every scenario, please tell Joe at-time could he go back home as early as possible. Every day Joe started he work at 08:00:00 am. The format of time is HH:MM:SS am|pm.

Sample Input2220 254018

Sample output08:00:40 am08:00:08 am

SOURCE Zhejiang University of Technology fourth session of college students Program design contest

recommendjgshining | We have carefully selected several similar problems for you:1257 1231 1074 1069 1159 DP State transfer equation for Dp[i]=min (dp[i-1]+a[i],d P[i-2]+b[i]) Dp[i] The minimum time it takes for a person to buy a ticket. A[i] and B[i] separately to buy tickets separately and two people to buy tickets together time. Because the debug statement did not delete and wrong put b[i] The following table is considered to be starting from 1 (the actual starting from 2) WA Two Fat 3A
#include <iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>using namespacestd;intn,k;Const  intinf=99999999;Const intn=2e3+5;BOOLam;inta[n],b[n],dp[n],hour,mini,sec;intMain () {scanf ("%d",&N);  while(n--) {am=true; Memset (A,0,sizeof(a)); memset (b,0,sizeof(b)); Hour=8; Mini=0; //cout<< "Hour1:" <         for(inti =0; i < N; i++) Dp[i]=0; //cout<< "HOUR2:" <scanf ("%d",&k);  for(inti =1; I <= K; i++) scanf ("%d",&A[i]);  for(inti =2; I <= K; i++) scanf ("%d",&B[i]); dp[1] = a[1];  for(inti =2; I <= K; i++) Dp[i]= Min (dp[i-1]+a[i],dp[i-2]+B[i]); //printf ("%d\n", Dp[k]);SEC =Dp[k]; //hour = 8; //cout<< "Hour:" <         while(sec>=3600) {sec= sec-3600 ; Hour++; }         while(sec>= -) {sec= sec- - ; Mini++; }        if(hour> A) {am=false; Hour= Hour- A; }        if(hour<Ten) cout<<"0"; cout<":"; if(mini<Ten) cout<<"0"; cout<<mini<<":"; if(sec<Ten) cout<<"0"; if(AM) cout<<sec<<"am"<<Endl; Elsecout<<sec<<"pm"<<Endl; }    return 0;}

[DP Special]HDU 1260 TICKETS

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.