hud 1260 Tickets (简单dp)
来源:互联网 发布:双系统软件不能用 编辑:程序博客网 时间:2024/05/21 18:31
又水一题~~
输出固定长度数字不足在前面添加0的情况就用%03d
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;int per[2010],pers[2010],dp[2010];int min(int x,int y) { if(x < y) return x; else return y;}int main() { int n,k,time; scanf("%d",&n); while(n--) { scanf("%d",&k); if(k == 1) { int t; scanf("%d",&t); printf("08:00:%02d am\n",t); continue; } for(int i = 1;i <= k;i++) scanf("%d",&per[i]); for(int i = 2;i <= k;i++) scanf("%d",&pers[i]); dp[1] = per[1]; dp[0] = 0; for(int i = 2;i <= k;i++) dp[i] = min(per[i]+dp[i-1],pers[i]+dp[i-2]); int time = dp[k]; int hour = 8+time/3600; int minute = (time%3600)/60; int sceond = time%60; if(hour == 12 && minute == 0 && sceond == 0) printf("12:00:00 am\n"); else if(hour >= 12) printf("%02d:%02d:%02d pm\n",hour-12,minute,sceond); else printf("%02d:%02d:%02d am\n",hour,minute,sceond); }}
0 0
- hud 1260 Tickets (简单dp)
- hdoj 1260 Tickets 【简单DP】
- HDU 1260 Tickets (简单DP)
- HDU 1260 Tickets 简单DP
- hdu Tickets 1260 (简单DP)
- HDU 1260 Tickets 简单dp
- HDU 1260 Tickets(简单DP)
- hdoj--1260--Tickets(简单dp)
- 【HDU】-1260-Tickets(简单DP)
- [简单DP]Tickets HDU
- hdu 1260 Tickets 【dp】
- hdu 1260 Tickets(dp)
- hdu 1260 tickets dp
- hdu 1260 Tickets dp
- 1260 Tickets【dp】
- HDU - 1260 Tickets(DP)
- DP-HDU-1260-Tickets
- HDU 1260 Tickets (DP)
- 【算法设计与分析】To the max
- 九、STL算法-排序算法(sort)
- C语言基础
- C语言---函数返回值探究
- android 视图自动注入的第三方库-ButterKnife插件用法介绍
- hud 1260 Tickets (简单dp)
- 关于app的几个核心功能的设计想法
- BZOJ 1115: [POI2009]石子游戏Kam
- oracle 12c:新特性-截断表CASCADE
- 【NOIP2016模拟赛No.1】 牛宫
- 计算时间复杂度
- hdu 5104 Primes Problem(素数判定)
- 冒泡排序的实现
- miller-rabin