302281: CF439A. Devu, the Singer and Churu, the Joker

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Devu, the Singer and Churu, the Joker

题意翻译

Devu 有一份歌曲清单:他会唱 n 首歌,第 ith 首歌要花 ti 分钟。 同时 Churu 会讲笑话,他所有的笑话都需要 5 分钟。 Devu 唱完每首歌后需要休息 10 分钟。 你应该为事件做出最佳的选择,需遵循以下条件: • 活动时间不得超过d分钟; • Devu 必须完成他的所有歌曲; • 在满足前两个条件的情况下,Churu 讲的笑话应尽可能多。 如果不可能找到一种方法使 Devu 唱完所有 的歌 ,输出 -1 ,否则找出 Churu 能讲的笑话数。

题目描述

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.

输入输出格式

输入格式


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) $ .

输出格式


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.

输入输出样例

输入样例 #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.

Input

题意翻译

Devu 有一份歌曲清单:他会唱 n 首歌,第 ith 首歌要花 ti 分钟。 同时 Churu 会讲笑话,他所有的笑话都需要 5 分钟。 Devu 唱完每首歌后需要休息 10 分钟。 你应该为事件做出最佳的选择,需遵循以下条件: • 活动时间不得超过d分钟; • Devu 必须完成他的所有歌曲; • 在满足前两个条件的情况下,Churu 讲的笑话应尽可能多。 如果不可能找到一种方法使 Devu 唱完所有 的歌 ,输出 -1 ,否则找出 Churu 能讲的笑话数。

加入题单

算法标签: