-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhdu 1260DP.txt
More file actions
47 lines (46 loc) · 836 Bytes
/
hdu 1260DP.txt
File metadata and controls
47 lines (46 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[2005];
int a[2005],b[2005];
int main()
{
int k,n;
cin>>k;
while(k--)
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<n;i++)
cin>>b[i];
dp[0]=0;
dp[1]=a[1];
for(int i=2;i<=n;i++)
dp[i]=min(dp[i-1]+a[i],dp[i-2]+b[i-1]);
int tot=dp[n];
int sec=tot%60;
tot/=60;
int mint=tot%60;
tot/=60;
int shi=tot;
if(8+shi<10)
cout<<0<<8+shi;
else
cout<<8+shi;
if(mint<10)
cout<<":"<<0<<mint;
else
cout<<":"<<mint;
if(sec<10)
cout<<":"<<0<<sec;
else
cout<<":"<<sec;
if(shi<12)
cout<<" am"<<endl;
if(shi>=12)
cout<<" pm"<<endl;
}
return 0;
}