纯属练习JAVA....

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.

import java.util.*;public class Main
{public static void main(String[] args){Scanner cin=new Scanner(System.in);int n=cin.nextInt(),d=cin.nextInt();int[] song=new int[n];int total=0;for(int i=0;i<n;i++){song[i]=cin.nextInt();total+=song[i];total+=10;}total-=10;int ans=0;if(total>d){ans=-1;}else{int left=d-total;ans+=left/5;ans+=(n-1)*2;}System.out.println(ans);}
}

Codeforces 439 A. Devu, the Singer and Churu, the Joker相关推荐

  1. codeforces 439A Devu, the Singer and Churu, the Joker

    网址:点击打开链接 A. Devu, the Singer and Churu, the Joker time limit per test 1 second memory limit per tes ...

  2. Codeforces 439A, the Singer and Churu, the Joker(水题)

    题目链接:Codeforces 439A Devu, the Singer and Churu, the Joker 题目大意:Devu是一个歌唱家,Churu是个小丑,他们被共同邀请参加一个表演秀, ...

  3. 时序数据取样方法_数据科学的抽样方法

    时序数据取样方法 语境 (Context) In most studies, it is pretty hard (or sometimes impossible) to analyse a whol ...

  4. 重走长征路---OI每周刷题记录---6月14日 2014

    总目录详见https://blog.csdn.net/mrcrack/article/details/84471041 做题原则,找不到测评地址的题不做.2018-11-28 重走长征路---OI每周 ...

  5. CodeForces - 1359

    CodeForces - 1359 A - Berland Poker 将尽可能多的joker牌先给一个人,剩下的k-1个人平均分,使得差值最大int t,n,m,k; int main() {sca ...

  6. Codeforces 439C Devu and Partitioning of the Array(模拟)

    题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...

  7. [CodeForces 439E] Devu and Birthday Celebration(莫比乌斯反演) | 错题本

    文章目录 题目 分析 代码 题目 [CodeForces 439E] Devu and Birthday Celebration 分析 莫比乌斯函数比较重要的性质: μ ∗ 1 = ε \mu * 1 ...

  8. Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组

    http://codeforces.com/contest/869/problem/E 题意:n*m的矩阵,q次操作,三种类型 类型1:给指定矩阵加上围栏 类型2:给指定矩阵去掉围栏 类型3:查询两点 ...

  9. Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学

    - This is not playing but duty as allies of justice, Nii-chan! - Not allies but justice itself, Onii ...

最新文章

  1. 蚂蚁森林最高效的合种团队—招募有合作精神的队友云植树
  2. Javascript中字符串转数字
  3. 图解Detours实例
  4. react监听input框里的值
  5. 软件测试理论入门(一)
  6. matlab解带参数的积分方程组,方程组求解问题:方程组中有带参数的积分函数,求参数...
  7. mybatis自动生成代码只有insert()和insertSelective()
  8. Java笔记-JSP初步研究
  9. 日常电脑小工具编程_如何使编程成为日常习惯
  10. CodeBlocks17.12+汉化包下载及用法
  11. postgresql和mysql语句区别_postgresql和mysql语句区别
  12. FIT2CLOUD飞致云完成C轮和C+轮融资,持续引领中国多云管理市场
  13. java中的date_Java中Date类型详解
  14. 软件生命周期创建B2C电子商务网站
  15. 武汉大学计算机学院 田海院长,玄跻峰 - 教师简历 CV- 武汉大学计算机学院
  16. 工作中常见的方法和法则(简单的法则不简单)
  17. 关于 error: invalid types ‘int[int]‘ for array subscript 的解决
  18. java 读取word页码
  19. [MTCTF]从出题人视角看ez_cms
  20. HTML5排序罗马数字,HTML5 罗马数字时钟

热门文章

  1. 爱思唯尔(Elsevier)论文模板中添加作者简介和图片(biography)
  2. R语言计算夹角余弦(Consine)
  3. mysql导出nb3文件_MySQL导入导出.sql文件
  4. MFC-CView类总结
  5. (附源码)ssm校园拼车服务系统 毕业设计211633
  6. 05.位图和比较器的简单应用
  7. 为什么说破壳漏洞会带来一场全球服务器的浩劫
  8. Unity3D与AvosCloud网游开发实践 - 单线程U3D中的异步通讯处理
  9. SAP API 开发方法大全
  10. 表白php制作教程视频,制作表白视频的软件 怎么制作出好看的表白小视频