Devu, the Singer and Churu, the Joker

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, ith song will take ti 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.

Input

The first line contains two space separated integers nd (1 ≤ n ≤ 100; 1 ≤ d ≤ 10000). The second line contains n space-separated integers: t1, t2, ..., tn (1 ≤ ti ≤ 100).

Output

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.

Examples

Input

3 30
2 2 1

Output

5

Input

3 20
2 1 1

Output

-1

Note

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.

问题链接:https://vjudge.net/contest/276590#problem/A

问题分析:唱歌和讲笑话一起总共时间不能超过d时间,唱歌与唱歌之间要间隔10分钟,一个笑话5分钟,输入歌曲数量n和总时间d和每首歌曲所需时间,若不能构成一个节目单,输出“-1”,否则计算并输出能讲笑话的最大数量。

解决办法:多组输入,定义一个数组a[100]存放歌曲时间,歌曲之间间隔时间j=(n-1)*10,利用循环结构计算总共所需时间sum,如果所需时间sum比输入的总时间d还要大,则说明时间不够,所以输出“-1”;否则,所需时间比输入时间小或者相等,计算笑话的最大个数:间隔时间笑话(数10分钟,有几个10分钟,每一个间隔讲2个笑话),再加上除了间隔时间和歌曲时间剩下的时间能讲多少个笑话。

#include <iostream>
using namespace std;

int main()
{
	int n, d;
	while (cin >> n >> d)
	{
		int i, j, sum;
		int a[100];
		for (i = 0;i < n;i++)
		{
			cin >> a[i];
		}
		j = (n - 1) * 10;
		sum = j;
		for (i = 0;i < n;i++)
		{
			sum = sum + a[i];
		}
		if (d < sum)cout << "-1";
		else cout << (d - sum) / 5 + j / 5;
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值