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