2014ACM大赛题目 下载本文

内容发布更新时间 : 2024/5/25 19:45:17星期一 下面是文章的全部内容请认真阅读。

题目描述

恶魔猎手尤迫安野心勃勃.他背叛了暗夜精灵,率深藏在海底的那加企图叛变:守望者在与尤迪安的交锋中遭遇了围杀.被困在一个荒芜的大岛上。为了杀死守望者,尤迪安开始对这个荒岛施咒,这座岛很快就会沉下去,到那时,刀上的所有人都会遇难:守望者的跑步速度,为17m/s, 以这样的速度是无法逃离荒岛的。庆幸的是守望者拥有闪烁法术,可在1s内移动60m,不过每次使用闪烁法术都会消耗魔法值10点。守望者的魔法值恢复的速度为4点/s,只有处在原地休息状态时才能恢复。

现在已知守望者的魔法初值M,他所在的初始位置与岛的出口之间的距离S,岛沉没的时间T。你的任务是写一个程序帮助守望者计算如何在最短的时间内逃离荒岛,若不能逃出,则输出守望者在剩下的时间内能走的最远距离。注意:守望者跑步、闪烁或休息活动均以秒(s)为单位。且每次活动的持续时间为整数秒。距离的单位为米(m)。

输入

输入文件escape.in仅一行,包括空格隔开的三个非负整数M,S,T。

输出

输出文件escape.out包含两行:

第1行为字符串\或\区分大小写),即守望者是否能逃离荒岛。

第2行包含一个整数,第一行为\区分大小写)时表示守望着逃离荒岛的最短时间 第一行为\区分大小写) 时表示守望者能走的最远距离。

样例输入

39 200 4

样例输出

No 197

提示

7 180 9 Yes

30%的数据满足: 1 <= T<= 10, 1 <=S<= 100

50%的数据满足: 1 <= T <= 1000, 1 <= S <= 10000

100%的数据满足: 1 <= T <= 300000, 0 <= M<=1000 1 <=S <= 10^8

题目描述

A group of friends has just completed their CS assignments, and because of the nice weather, they decide to go to Joe's house for a BBQ. Unfortunately, after all that coding, they are too tired to walk. Fortunately, between them they have enough cars to take everyone.

Joe remembers that he needs to stop off at the supermarket along the way to buy some burgers and pop.

Jenn proposes that they stop at her house to get a frisbee.

Jim decides that he doesn't like burgers, and wants to grab a pizza along the way. After having spent so long in the computer lab, Jerry's eyes have become very sensitive to sunlight, so he needs to stop at his house for his sunglasses.

And so it goes: each person needs to run a little errand along the way. At this rate, the friends worry that it will be dark by the time they get to Joe's house. They launch into a heated discussion to about who should go in which car to minimize the time needed for everyone to reach Joe's house. The discussion itself, of course, wastes precious time that could be better spent at the BBQ.

To help the group, you will write a program to settle the discussion by computing an optimal assignment of people to cars. The overall travel time is the maximum of the

travel times of each car. An optimal assignment is one that minimizes the overall travel time.

Your program will be provided with a representation of the roads in the city, in the form of distances between major landmarks. Assume that every car always travels at 60 kilometres per hour (one kilometre per minute). Each stop (at a supermarket, someone's house, etc.) takes five minutes.

Although the friends have many cars between them, to be nice to the environment, they decide to take no more cars than necessary. Each car can take at most five people.

输入

The first line of input contains two integers n and m, 1 ≤ n ≤ 15, 1 ≤ m ≤ 1000, the number of people in the group and the number of roads in the city. The places that must be visited along the way are numbered 1 through n. The campus is numbered 0, and Joe's house is numbered n+1. An additional m lines follow, each containing three integers describing a stretch of road. The first two integers are in the range 0 to n+1 inclusive, and describe the two places connected by the stretch of road. The third integer specifies the length of the stretch of road, in kilometres. A road may be taken in both directions. There is a sequence of roads connecting every place in the city to every other place.

输出

Output a single integer, giving the number of minutes required for everyone to reach Joe's house using an optimal assignment of people to cars.

样例输入