Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1935 Accepted Submission(s):
933
#include<stdio.h> #include<string.h> #define MAX 2100 #define min(x,y)(x<y?x:y) int a[MAX],b[MAX],dp[MAX]; int main() { int t,i,j,n; int h,m,s; int sum,tot; scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=2;i<=n;i++) scanf("%d",&b[i]); dp[1]=a[1]; for(i=2;i<=n;i++) dp[i]=min(dp[i-1]+a[i],dp[i-2]+b[i]); //printf("%d\n",dp[n]); sum=dp[n]; h=0;s=0;m=0; s=sum%60; m=(sum-s)/60; if(m>=60) { h=h+m/60; m=m%60; } h=8+h; if(h<=12) printf("%02d:%02d:%02d am\n",h,m,s); else { h-=12; printf("%02d:%02d:%02d pm\n",h,m,s); } } return 0; }
原文:http://www.cnblogs.com/tonghao/p/4737286.html