Codeforces 439 A. Devu, the Singer and Churu, the Joker
纯属练习JAVA....
1 second
256 megabytes
standard input
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.
The first line contains two space separated integers n, d (1 ≤ n ≤ 100; 1 ≤ d ≤ 10000). The second line contains n space-separated integers: 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.
3 30 2 2 1
5
3 20 2 1 1
-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.
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相关推荐
- 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 ...
- Codeforces 439A, the Singer and Churu, the Joker(水题)
题目链接:Codeforces 439A Devu, the Singer and Churu, the Joker 题目大意:Devu是一个歌唱家,Churu是个小丑,他们被共同邀请参加一个表演秀, ...
- 时序数据取样方法_数据科学的抽样方法
时序数据取样方法 语境 (Context) In most studies, it is pretty hard (or sometimes impossible) to analyse a whol ...
- 重走长征路---OI每周刷题记录---6月14日 2014
总目录详见https://blog.csdn.net/mrcrack/article/details/84471041 做题原则,找不到测评地址的题不做.2018-11-28 重走长征路---OI每周 ...
- CodeForces - 1359
CodeForces - 1359 A - Berland Poker 将尽可能多的joker牌先给一个人,剩下的k-1个人平均分,使得差值最大int t,n,m,k; int main() {sca ...
- Codeforces 439C Devu and Partitioning of the Array(模拟)
题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...
- [CodeForces 439E] Devu and Birthday Celebration(莫比乌斯反演) | 错题本
文章目录 题目 分析 代码 题目 [CodeForces 439E] Devu and Birthday Celebration 分析 莫比乌斯函数比较重要的性质: μ ∗ 1 = ε \mu * 1 ...
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组
http://codeforces.com/contest/869/problem/E 题意:n*m的矩阵,q次操作,三种类型 类型1:给指定矩阵加上围栏 类型2:给指定矩阵去掉围栏 类型3:查询两点 ...
- 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 ...
最新文章
- 蚂蚁森林最高效的合种团队—招募有合作精神的队友云植树
- Javascript中字符串转数字
- 图解Detours实例
- react监听input框里的值
- 软件测试理论入门(一)
- matlab解带参数的积分方程组,方程组求解问题:方程组中有带参数的积分函数,求参数...
- mybatis自动生成代码只有insert()和insertSelective()
- Java笔记-JSP初步研究
- 日常电脑小工具编程_如何使编程成为日常习惯
- CodeBlocks17.12+汉化包下载及用法
- postgresql和mysql语句区别_postgresql和mysql语句区别
- FIT2CLOUD飞致云完成C轮和C+轮融资,持续引领中国多云管理市场
- java中的date_Java中Date类型详解
- 软件生命周期创建B2C电子商务网站
- 武汉大学计算机学院 田海院长,玄跻峰 - 教师简历 CV- 武汉大学计算机学院
- 工作中常见的方法和法则(简单的法则不简单)
- 关于 error: invalid types ‘int[int]‘ for array subscript 的解决
- java 读取word页码
- [MTCTF]从出题人视角看ez_cms
- HTML5排序罗马数字,HTML5 罗马数字时钟