本文主要是介绍HDU - 1260 Tickets,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
传送门
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
using namespace std;typedef long long LL; //数据太大了记得用LL,还有把INF也得换
typedef pair<int, int> P;const int maxn = 1e7+10; //cf数组最多差不多是这么多,1e8就会段错误
const int V_MAX = 800 + 10;
const int mod = 10007;
const int INF = 0x3f3f3f3f; //如果数据范围为long long,记得把INF的值换了
const double eps = 1e-6; //eps开太小二分容易死循环,所以直接来个100次循环就好了//多组输入时,maxn太大,用memset()会超时,血的教训;//dp[i]表示前i个人买票耗费的最小时间;
//dp[i] = min(dp[i-1] + tm[i], dp[i-2] + atm[2]);void solve() {int n; cin >> n;int tm[n+1], atm[n+1];for(int i = 1; i <= n; i++) scanf("%d", &tm[i]);atm[0] = INF;for(int i = 2; i <= n; i++) scanf("%d", &atm[i]);int dp[n+1];for(int i = 0; i <= n; i++) dp[i] = INF;dp[1] = tm[1];dp[0] = 0;for(int i = 2; i <= n; i++) dp[i] = min(dp[i-2] + atm[i], dp[i-1] + tm[i]);int hh = 8,mm = 0, ss = 0;ss = dp[n] % 60;mm = dp[n] / 60;hh += mm / 60;mm %= 60;if(hh >= 12) printf("%02d:%02d:%02d pm\n", hh, mm, ss);else printf("%02d:%02d:%02d am\n", hh, mm, ss);
}int main()
{//ios::sync_with_stdio(false); //关了流同步就别用c的输入//freopen("D:\\in.txt", "r", stdin);int t; cin >> t;while(t--) {solve();}return 0;
}
这篇关于HDU - 1260 Tickets的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!