UVa11958 - Coming Home

简介: UVa11958 - Coming Home
#include <cstdio>#include <climits>usingnamespacestd;
constintN=110;
constintDAY=24*60;
structBus{
intarriveTime, travelTime;
};
Busbus[N];
intn, curTime;
boolinput();
intsolve();
intmain()
{
#ifndef ONLINE_JUDGEfreopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endifintt;
scanf("%d", &t);
for (inti=1; i<=t; i++) {
input();
printf("Case %d: %d\n", i, solve());
    }
return0;
}
boolinput()
{
inth, m;
scanf("%d %d:%d", &n, &h, &m);
curTime=h*60+m;
for (inti=0; i<n; i++) {
scanf("%d:%d %d", &h, &m, &bus[i].travelTime);
bus[i].arriveTime=h*60+m;
    }
returntrue;
}
intsolve()
{
intans=INT_MAX;
for (inti=0; i<n; i++) {
if (curTime>bus[i].arriveTime) {
bus[i].arriveTime+=DAY;
        }
intcost=bus[i].arriveTime-curTime+bus[i].travelTime;
if (cost<ans) ans=cost;
    }
returnans;
}
目录
相关文章
UVa355 - The Bases Are Loaded
UVa355 - The Bases Are Loaded
52 0
[USACO 2021.02 Feb]Problem 3. Clockwise Fence
[USACO 2021.02 Feb]Problem 3. Clockwise Fence
UVa11565 - Simple Equations
UVa11565 - Simple Equations
53 0
|
数据库
When Tech Meets Love – Smarter Ways to NOT be Single
It’s that time of year again. Single’s Day (a.k.a Double 11) is just around the corner, people buying gifts for loved ones.
1634 0
When Tech Meets Love – Smarter Ways to NOT be Single
POJ 1276 Cash Machine 解答
题目详见: http://poj.org/problem?id=1276 这道题与POJ 1014同属一类题, 区别在于POJ 1014的解是求恰好等于容量的情况, 而这道题较为常规, 同时这道题的数据较大, 套用我在博客http://blog.
900 0
uva live 3516 - Exploring Pyramids
点击打开链接 题意:给出一棵多叉树,每个结点的任意两个子节点都有左右之分。从根节点开始,每次尽量往左走,走不通就回溯,把遇到的字母顺序记录下来,可以得到一个序列。
773 0