标签:inpu logs 大学生 stream names hdu wan 工业 竞赛
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3917 Accepted Submission(s): 1968
1 //2017-04-04 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 7 using namespace std; 8 9 int s[2005], d[2005], dp[2005];//dp[i]表示前i个人所需要的最短时间 10 //状态转移方程:dp[i] = min(dp[i-1]+s[i], dp[i-2]+d[i-1]) 11 12 int main() 13 { 14 int T, n; 15 scanf("%d", &T); 16 while(T--) 17 { 18 scanf("%d", &n); 19 for(int i = 0; i < n; i++) 20 scanf("%d", &s[i]); 21 for(int i = 0; i < n-1; i++) 22 scanf("%d", &d[i]); 23 dp[0] = s[0]; 24 dp[1] = min(dp[0]+s[1], d[0]); 25 for(int i = 2; i < n; i++) 26 dp[i] = min(dp[i-1]+s[i], dp[i-2]+d[i-1]); 27 int h, m, s; 28 h = 8+dp[n-1]/3600; 29 m = (dp[n-1]%3600)/60; 30 s = dp[n-1]%60; 31 if(h < 12)printf("%02d:%02d:%02d am\n", h, m, s); 32 else printf("%02d:%02d:%02d pm\n", h, m, s); 33 } 34 35 return 0; 36 }
标签:inpu logs 大学生 stream names hdu wan 工业 竞赛
原文地址:http://www.cnblogs.com/Penn000/p/6664822.html