http://acm.hdu.edu.cn/showproblem.php?pid=1260
at first it was thought that a man could only be greedy with one of his neighbors .
In fact, a person (if both front and back) can be used to the greed of many times
Tickets
time limit:2000/1000 MS (java/others) memory limit:65536/32768 K (java/others) Total Submission (s): 3141 accepted submission (s): 1540
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 1160 1231 1074 1069
#include <cstdio>#include<cstring>#include<iostream>#include<cmath>#include<vector>#include<algorithm>using namespacestd;#definePI 3.1415926Const intmaxn=10007;Const intinf=0x3f3f3f3f;intDP[MAXN], A[MAXN], C[MAXN];intMain () {intT; scanf ("%d", &u); while(t--) { intN; scanf ("%d", &N); for(intI=1; i<=n; i++) scanf ("%d", &A[i]); for(intI=2; i<=n; i++) scanf ("%d", &C[i]); Memset (DP,0,sizeof(DP)); dp[1]=a[1]; ///at first it was thought that a man could only be greedy with one of his neighbors .///In fact, a person (if both front and back) can be used to the greed of many times for(intI=2; i<=n; i++) Dp[i]=min (dp[i-1]+a[i], dp[i-2]+C[i]); inthh=dp[n]/3600; intMm= (dp[n]%3600)/ -; intss=dp[n]% -; printf ("%02d:%02d:%02d%s\n", (hh+8)% -, MM, SS, (hh+8)% -> A?"pm":"am"); } return 0;}
HDU---1260---tickets