程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Codeforces 439 A. Devu, the Singer and Churu, the Joker,codeforcesdevu

Codeforces 439 A. Devu, the Singer and Churu, the Joker,codeforcesdevu

編輯:C++入門知識

Codeforces 439 A. Devu, the Singer and Churu, the Joker,codeforcesdevu


 這是本人第一次寫代碼,難免有點瑕疵還請見諒                                                                                          

A. Devu, the Singer and Churu, the Joker time limit per test  1 second memory limit per test  256 megabytes input  standard input output  standard output

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.

Sample test(s) 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.

 

 

關於這題的解題報告:本人覺得當你想多了的時候就會把太多的時間浪費掉了,因為本人就體驗過,算了發了一下牢騷就打住吧;

對於這題:基本思路就是簡單的模擬;

下面就是本人的代碼:

 1 #include<cstdio>
 2 #define N 100
 3 
 4 int t[N];
 5 int main()
 6 {
 7     int d,n;
 8     int Sum = 0;
 9     int count = 0;
10     
11     scanf("%d%d",&n,&d);
12     for(int i=1;i<=n;++i){
13         scanf("%d",&t[i]);
14         Sum += t[i];
15     }
16     Sum += (n-1)*10;
17     if(Sum > d)
18          printf("-1\n");
19     else
20     {
21         count += (n-1)*2;
22         printf("%d\n",count+(d-Sum)/5);
23     }
24     int a;scanf("%d\n",&a);
25     return 0;
26 }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved