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;
}
目录
相关文章
uva 11991 - Easy Problem from Rujia Liu?
这个题目的意思是输入n个数,m组询问,每组询问包含两个整数k,v,意思是询问整数v第k次出现的位置。
39 0
|
6月前
UVA —10361—Automatic Poetry
UVA —10361—Automatic Poetry
|
6月前
Strange fuction(HDU--2899)
Strange fuction(HDU--2899)
UVa389 - Basically Speaking
UVa389 - Basically Speaking
36 0
|
人工智能 C++ BI
uva live 3516 - Exploring Pyramids
点击打开链接 题意:给出一棵多叉树,每个结点的任意两个子节点都有左右之分。从根节点开始,每次尽量往左走,走不通就回溯,把遇到的字母顺序记录下来,可以得到一个序列。
769 0