HDOJ-1260(动态规划水题)
Tickets
HDOJ-1260
#include<bits/stdc++.h>
using namespace std;
const int maxn=2003;
int n;
int s[maxn];//single
int d[maxn];//double
int dp[maxn];//dp[i]表示前i个人买好票花费的最小费用
int main(){
int t;
cin>>t;
while(t--){
cin>>n;
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++){
cin>>s[i];
}
for(int i=2;i<=n;i++){
cin>>d[i];
}
d[1]=s[1];
dp[1]=s[1];
for(int i=2;i<=n;i++){
dp[i]=min(dp[i-1]+s[i],dp[i-2]+d[i]);
}
//cout<<dp[n]<<endl;
int seconds=dp[n];
int hours=seconds/3600;
int minutes=(seconds%3600)/60;
seconds=seconds-hours*3600-minutes*60;
if(hours>=4){
printf("%02d:%02d:%02d pm\n",8+hours,minutes,seconds);
}else{
printf("%02d:%02d:%02d am\n",8+hours,minutes,seconds);
}
}
//system("pause");
return 0;
}
HDOJ-1260(动态规划水题)的更多相关文章
- 动态规划(水题):COGS 261. [NOI1997] 积木游戏
261. [NOI1997] 积木游戏 ★★ 输入文件:buildinggame.in 输出文件:buildinggame.out 简单对比时间限制:1 s 内存限制:128 MB S ...
- HDOJ 1070 Milk(水题,考英文的)
Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to choo ...
- poj--3624--Charm Bracelet(动态规划 水题)
Home Problem Status Contest Add Contest Statistic LOGOUT playboy307 UPDATE POJ - 3624 Charm Bracelet ...
- USACO 2008 Mar Silver 3.River Crossing 动态规划水题
Code: #include<cstring> #include<algorithm> #include<cstdio> using namespace std; ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- 水题 HDOJ 4727 The Number Off of FFF
题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...
- 水题 HDOJ 4716 A Computer Graphics Problem
题目传送门 /* 水题:看见x是十的倍数就简单了 */ #include <cstdio> #include <iostream> #include <algorithm ...
- 动态规划之HDU水题
做水题的感觉真好系列 HDU 2084 数塔 1: 12: 1 23: 1 2 34: 1 2 3 45: 1 2 3 4 5 dp[i][j]第i行第j个数取得的最大值dp[i][j] = max( ...
- HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...
随机推荐
- Codeforces Round #555 (Div. 3) E. Minimum Array (贪心,二分,set)
题意:给你两个长度为\(n\)的数组\(a\)和\(b\),元素值在\([0,n-1]\),可以对\(b\)数组的元素任意排序,求新数组\(c\),满足\(c_i=(a_i+b_i)\ mod\ n\ ...
- .net面试--值类型和引用类型
注:下面的示意图主要是为了辅助理解,不代表内存真实情况. Introduction 类型基础是C#的基础概念,了解类型基础及背后的工作原理更有助于我们在编码的时候明白数据在内存中的分配与传递.C#提供 ...
- HTTP 请求过程以及报文结构
目录 HTTP 请求流程 HTTP 请求报文 请求行 方法字段(Request Method) URL字段(Uniform Resource Locator) HTTP 协议版本字段(略) 请求/响应 ...
- codevs1169传纸条 不相交路径取最大,四维转三维DP
这个题一个耿直的思路肯定是先模拟.. 但是我们马上发现这是具有后效性的..也就是一个从(1,1)开始走,一个从(n,m)开始走的话 这样在相同的时间点我们就没法判断两个路径是否是相交的 于是在dp写挂 ...
- sqlmap在https情况下的一个错误
对于https网站,使用sqlmap可能会出现如下错误.使用–force-ssl无效. https证书有问题 方法 本地建立proxy.php,内容为 <?php $url = "ht ...
- 让你像黑客一样写代码(not really)
让你像黑客一样写代码(not really) http://poznan.tvp.pl 这是一个波兰的视频网站. poznan 波兹南(波兰城市 视屏链接 http://video.sina.com. ...
- GraphQL API In Action
GraphQL API In Action GraphQL API express $ yarn add express express-graphql graphql # OR $ npm i -S ...
- GitHub & Hacker & MicroSoft
GitHub & Hacker & MicroSoft GitHub源码被黑客洗劫和勒索事件 微软也未能幸免 https://www.cnbeta.com/articles/tech/ ...
- JavaScript Semicolon Insertion
JavaScript Semicolon Insertion https://blog.izs.me/2010/12/an-open-letter-to-javascript-leaders-rega ...
- git include只包含某些文件
.gitignore: * # include !.gitignore !a.txt !dir2