Tickets
Descriptions:
Input
Give N (1 <= N <= 10), expressed set of sample N
Is given K (1 <= K <= 2000), expressed personal buying K ..
K represents the number of the person is given a separate ticket will spend time to ensure that each number .. (0s <= Si <= 25s)
It gives the number of K-1, and the man indicates that this ticket would spend time with each of the number of guaranteed .. (0s <= Si <= 50s)
the Output
For each set of data, you need to give cinema ticketing end of time, the time is 08:00:00 am start ticketing time format:. HH: MM:. SS am / pm specifically to see the sample output
Sample Input
2
2
20 25
40
1
8
Sample Output
08:00:40 am
08:00:08 am
Topic links:
https://vjudge.net/problem/HDU-1260
DP [i] denotes the front i need individual time a [i] denotes the i-buying their own individual time b [i] denotes the i-th individual time i-1 and the individual tickets needed
Person i he may himself buy (dp [i] == dp [i-1] + a [i]) and the front of a person or together to buy (dp [i] = dp [i-2] + b [i] )
AC Code
#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #include <queue> #include <string> #include <cstring> #include <map> #include <stack> #include <set> #define Mod 1000000007 #define eps 1e-6 #define ll long long #define INF 0x3f3f3f3f #define MEM(x, y) memset(x, y, sizeof(x)) #define Maxn 2000+10 using namespace std; int n,k; int a[Maxn]; int b[Maxn]; int dp[Maxn]; int main() { cin>>n; while(n--) { MEM(dp,0);//初始化 cin>>k; for(int i=1; i<=k; i++) cin>>a[i]; for(intJ = 2 ; J <= K; J ++ ) CIN >> B [J]; DP [ . 1 ] = A [ . 1 ]; DP [ 2 ] = min (A [ . 1 ] + A [ 2 ], B [ 2 ] ); for ( int I = . 3 ; I <= K; I ++) // starting from the third person DP DP [I] = min (DP [I- . 1 ] + A [I], DP [I- 2 ] + B [I]); int H DP = [K] / 3600 + . 8 ; // calculation time int m = DP [K]% 3600 /60; int s=dp[k]%60; if(h>12) printf("%02d:%02d:%02d pm\n", h-12, m, s); else printf("%02d:%02d:%02d am\n", h, m, s); } return 0; }