标签:mis include main person queue rest panel ack second
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1260
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5097 Accepted Submission(s): 2673
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <vector> 7 #include <queue> 8 #include <stack> 9 #include <map> 10 #include <string> 11 #include <set> 12 #define ms(a,b) memset((a),(b),sizeof((a))) 13 using namespace std; 14 typedef long long LL; 15 const double EPS = 1e-8; 16 const int INF = 2e9; 17 const LL LNF = 2e18; 18 const int MAXN = 2e3+10; 19 20 int dp[MAXN][MAXN][2], a[MAXN], b[MAXN]; 21 22 int main() 23 { 24 int T, n; 25 scanf("%d", &T); 26 while(T--) 27 { 28 scanf("%d", &n); 29 for(int i = 1; i<=n; i++) scanf("%d", &a[i]); 30 for(int i = 1; i<n; i++) scanf("%d", &b[i]); 31 32 for(int i = 0; i<=n; i++) 33 for(int j = 0; j<=n; j++) 34 dp[i][j][0] = dp[i][j][1] = INF/2; 35 36 dp[0][0][0] = 0; 37 for(int i = 1; i<=n; i++) 38 for(int j = (i+1)/2; j<=i; j++) 39 { 40 dp[i][j][0] = dp[i-1][j][1] - a[i-1] + b[i-1]; 41 dp[i][j][1] = min(dp[i-1][j-1][0], dp[i-1][j-1][1]) + a[i]; 42 } 43 44 int time = INF; 45 for(int i = (n+1)/2; i<=n; i++) 46 time = min(time, min(dp[n][i][0], dp[n][i][1]) ); 47 48 int second = time%60; 49 int minute = (time/60)%60; 50 int hour = time/3600 + 8; 51 52 int id = 0; 53 if(hour>12){ 54 id = 1; 55 hour = hour-12; 56 } 57 printf("%02d:%02d:%02d %s\n", hour, minute, second, id?"pm":"am"); 58 } 59 }
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <vector> 7 #include <queue> 8 #include <stack> 9 #include <map> 10 #include <string> 11 #include <set> 12 #define ms(a,b) memset((a),(b),sizeof((a))) 13 using namespace std; 14 typedef long long LL; 15 const double EPS = 1e-8; 16 const int INF = 2e9; 17 const LL LNF = 2e18; 18 const int MAXN = 2e3+10; 19 20 int dp[MAXN][2], a[MAXN], b[MAXN]; 21 22 int main() 23 { 24 int T, n; 25 scanf("%d", &T); 26 while(T--) 27 { 28 scanf("%d", &n); 29 for(int i = 1; i<=n; i++) scanf("%d", &a[i]); 30 for(int i = 1; i<n; i++) scanf("%d", &b[i]); 31 32 for(int i = 0; i<=n; i++) 33 dp[i][0] = dp[i][1] = INF/2; 34 35 dp[0][0] = 0; 36 for(int i = 1; i<=n; i++) 37 { 38 dp[i][0] = dp[i-1][1] - a[i-1] + b[i-1]; 39 dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + a[i]; 40 } 41 int time = min(dp[n][0], dp[n][1]); 42 43 int second = time%60; 44 int minute = (time/60)%60; 45 int hour = time/3600 + 8; 46 47 int id = 0; 48 if(hour>12){ 49 id = 1; 50 hour = hour-12; 51 } 52 printf("%02d:%02d:%02d %s\n", hour, minute, second, id?"pm":"am"); 53 } 54 }
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <vector> 7 #include <queue> 8 #include <stack> 9 #include <map> 10 #include <string> 11 #include <set> 12 #define ms(a,b) memset((a),(b),sizeof((a))) 13 using namespace std; 14 typedef long long LL; 15 const double EPS = 1e-8; 16 const int INF = 2e9; 17 const LL LNF = 2e18; 18 const int MAXN = 2e3+10; 19 20 int dp[MAXN], a[MAXN], b[MAXN]; 21 22 int main() 23 { 24 int T, n; 25 scanf("%d", &T); 26 while(T--) 27 { 28 scanf("%d", &n); 29 for(int i = 1; i<=n; i++) scanf("%d", &a[i]); 30 for(int i = 1; i<n; i++) scanf("%d", &b[i]); 31 32 dp[0] = 0; dp[1] = a[1]; 33 for(int i = 2; i<=n; i++) 34 dp[i] = min(dp[i-1]+a[i], dp[i-2]+b[i-1]); 35 36 int second = dp[n]%60; 37 int minute = (dp[n]/60)%60; 38 int hour = dp[n]/3600 + 8; 39 40 int id = 0; 41 if(hour>12){ 42 id = 1; 43 hour = hour-12; 44 } 45 printf("%02d:%02d:%02d %s\n", hour, minute, second, id?"pm":"am"); 46 } 47 }
标签:mis include main person queue rest panel ack second
原文地址:http://www.cnblogs.com/DOLFAMINGO/p/7624600.html