CF439A.Devu, the Singer and Churu, the Joker
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.
Devu has provided organizers a list of the songs and required time for singing them. He will sing n songs, i__th song will take t__i minutes exactly.
The Comedian, Churu will crack jokes. All his jokes are of 5 minutes exactly.
People have mainly come to listen Devu. But you know that he needs rest of 10 minutes after each song. On the other hand, Churu being a very active person, doesn't need any rest.
You as one of the organizers should make an optimal sсhedule for the event. For some reasons you must follow the conditions:
- The duration of the event must be no more than d minutes;
- Devu must complete all his songs;
- With satisfying the two previous conditions the number of jokes cracked by Churu should be as many as possible.
If it is not possible to find a way to conduct all the songs of the Devu, output -1. Otherwise find out maximum number of jokes that Churu can crack in the grand event.
德武是一位著名的古典歌手,他受邀参加许多大型活动或节日。最近,他被邀请参加“全球古典歌唱节”。除了德武之外,喜剧演员楚鲁也被邀请出席。
德武已向主办方提供了一份歌曲列表以及演唱每首歌所需的时间。他将演唱 n 首歌,其中第 i 首歌恰好耗时 ti 分钟。
喜剧演员楚鲁则负责讲笑话,他每个笑话的时长恰好为 5 分钟。
观众主要是来听德武演唱的。但众所周知,德武每唱完一首歌后都需要休息 10 分钟。而楚鲁则非常活跃,不需要任何休息时间。
作为主办方之一,你需要为本次活动制定一个最优的日程安排。出于某些原因,你必须满足以下条件:
- 活动总时长不得超过 d 分钟;
- 德武必须完整演唱全部歌曲;
- 在满足上述两个条件的前提下,楚鲁所讲的笑话数量应尽可能多。
如果无法安排使得德武能完整演唱所有歌曲,则输出 -1;否则,请计算出楚鲁在本次盛会中最多能讲多少个笑话。
输入格式
The first line contains two space separated integers n, d (1 ≤ n ≤ 100; 1 ≤ d ≤ 10000). The second line contains n space-separated integers: _t_1, _t_2, ..., t__n (1 ≤ t__i ≤ 100).
第一行包含两个用空格分隔的整数 n、d(1 ≤ n ≤ 100;1 ≤ d ≤ 10000)。第二行包含 n 个用空格分隔的整数:t1,t2,...,tn(1 ≤ ti ≤ 100)。
输出格式
If there is no way to conduct all the songs of Devu, output -1. Otherwise output the maximum number of jokes that Churu can crack in the grand event.
如果无法演唱 Devu 的所有歌曲,则输出 -1;否则输出 Churu 在盛大活动中能讲的最大笑话数量。
输入输出样例
输入#1
3 30 2 2 1
输出#1
5
输入#2
3 20 2 1 1
输出#2
-1
说明/提示
Consider the first example. The duration of the event is 30 minutes. There could be maximum 5 jokes in the following way:
- First Churu cracks a joke in 5 minutes.
- Then Devu performs the first song for 2 minutes.
- Then Churu cracks 2 jokes in 10 minutes.
- Now Devu performs second song for 2 minutes.
- Then Churu cracks 2 jokes in 10 minutes.
- Now finally Devu will perform his last song in 1 minutes.
Total time spent is 5 + 2 + 10 + 2 + 10 + 1 = 30 minutes.
Consider the second example. There is no way of organizing Devu's all songs. Hence the answer is -1.
考虑第一个例子。活动持续时间为 30 分钟。最多可以讲 5 个笑话,具体安排如下:
- 首先,Churu 用 5 分钟讲一个笑话。
- 接着,Devu 演唱第一首歌曲,耗时 2 分钟。
- 然后,Churu 用 10 分钟讲 2 个笑话。
- 接下来,Devu 演唱第二首歌曲,耗时 2 分钟。
- 然后,Churu 再用 10 分钟讲 2 个笑话。
- 最后,Devu 演唱最后一首歌曲,耗时 1 分钟。
总耗时为 5 + 2 + 10 + 2 + 10 + 1 = 30 分钟。
考虑第二个例子。不存在一种方式能安排 Devu 的所有歌曲。因此答案为 −1。
输入解题思路,AI测评打分。不知道怎么写?