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 ...
随机推荐
- P3381 [模板] 最小费用最大流
EK + dijkstra (2246ms) 开氧气(586ms) dijkstra的势 可以处理负权 https://www.luogu.org/blog/28007/solution-p3381 ...
- Codeforces Round #697 (Div. 3) D. Cleaning the Phone (思维,前缀和)
题意:你的手机有\(n\)个app,每个app的大小为\(a_i\),现在你的手机空间快满了,你需要删掉总共至少\(m\)体积的app,每个app在你心中的珍惜值是\(b_i\),\(b_i\)的取值 ...
- python的threading的使用(join方法,多线程,锁threading.Lock和threading.Condition
一.开启多线程方法一 import threading,time def write1(): for i in range(1,5): print('1') time.sleep(1) def wri ...
- hdu4339 Query
Problem Description You are given two strings s1[0..l1], s2[0..l2] and Q - number of queries. Your t ...
- poj 2566 Bound Found 尺取法
一.首先介绍一下什么叫尺取 过程大致分为四步: 1.初始化左右端点,即先找到一个满足条件的序列. 2.在满足条件的基础上不断扩大右端点. 3.如果第二步无法满足条件则到第四步,否则更新结果. 4.扩大 ...
- Codeforces Round #650 (Div. 3) C. Social Distance (前缀和)
题意:有一排座位,要求每人之间隔\(k\)个座位坐,\(1\)代表已做,\(0\)代表空座,问最多能坐几人. 题解:我们分别从前和从后跑个前缀和,将已经有人坐的周围的位置标记,然后遍历求每一段连续的\ ...
- entity framwork修改指定字段
1.ef修改时指修改指定字段public void ChangePassword(int userId, string password) { var user = new User() { Id = ...
- Spring Cloud实战 | 第十一篇:Spring Cloud Gateway 网关实现对RESTful接口权限控制和按钮权限控制
一. 前言 hi,大家好,这应该是农历年前的关于开源项目 的最后一篇文章了. 有来商城 是基于 Spring Cloud OAuth2 + Spring Cloud Gateway + JWT实现的统 ...
- 通过修改etcd来设置或修改节点flannel子网信息
在首次启动flannel服务的时候可以手动指定subnet.env文件,配置所在节点的flannel子网网段,如果不指定配置文件,flannel将自动分配一个子网网段并生成配置文件 /var/run/ ...
- 图解算法——链表中倒数第k个节点
题目来源: 剑指 Offer 22. 链表中倒数第k个节点 leetCode 题目描述: 输入一个链表,输出该链表中倒数第k个节点.为了符合大多数人的习惯,本题从1开始计数,即链表的尾节点是倒数第1个 ...