codeforces 439A Devu, the Singer and Churu, the Joker
网址:点击打开链接
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.
标签虽然要用贪心,但是不用也可以!
#include<stdio.h>
int main()
{int n,d,s=0,x;scanf("%d%d",&n,&d);for(int i=0; i<n; i++){scanf("%d",&x);s+=x;}int w=(n-1)*10;if(w+s>d){printf("-1\n");return 0;}if(d-w-s>=5)printf("%d\n",(n-1)*2+(d-w-s)/5);elseprintf("%d\n",2*(n-1));return 0;
}
codeforces 439A Devu, the Singer and Churu, the Joker相关推荐
- Codeforces 439 A. Devu, the Singer and Churu, the Joker
纯属练习JAVA.... A. Devu, the Singer and Churu, the Joker time limit per test 1 second memory limit per ...
- Codeforces 439A, the Singer and Churu, the Joker(水题)
题目链接:Codeforces 439A Devu, the Singer and Churu, the Joker 题目大意:Devu是一个歌唱家,Churu是个小丑,他们被共同邀请参加一个表演秀, ...
- 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 ...
- 时序数据取样方法_数据科学的抽样方法
时序数据取样方法 语境 (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 难度:2000 ~ 3000 + )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量的题解和代码,题目难度不一 ...
- cf451E. Devu and Flowers(产生不同多重集数量)
cf451E. Devu and Flowers 题意: 有n个箱子,第i个箱子里有ai朵花,同一个箱子里花的颜色一样,不同箱子里的花颜色不一样.现在在这些箱子里选出m朵花组成一束,求一共有多少种方案 ...
- # CF451 - Devu and Flowers
CF451 - Devu and Flowers n倍经验题: CF451E Devu and Flowers - 洛谷 codeforces传送门 感觉算法进阶指南的题目有空还是要都刷一下 题意: ...
最新文章
- Windows下JSON可视化工具
- 使用CocoaPods出现 The `master` repo requires CocoaPods 0.32.1 - 问题解决
- 亮度均匀性 matlab,求:亮度保持的夜景图像直方图均衡算法 matlab程序
- android json 解析图片,JSON解析并获取android中的图像
- python中的__new__概念(工厂
- ROL与RCL的差别
- JS常用的设计模式(2)——简单工厂模式
- c语言打开文件出现分段故障,c fclose() 导致分段故障_segmentation-fault_开发99编程知识库...
- 华为Mate10到底AI在哪?
- SSE指令介绍及其C、C++应用 zz
- thinkphp5 数据库 链接 Connection
- 【CoreBluetooth】iOS 系统蓝牙框架
- Python手册(Machine Learning)--statsmodels(TimeSeries)
- 如何使用linux系统下载BT?
- 猜数字游戏程序,随机生成一个1~10之间的数,并让用户输入一个数字 猜测
- 如何修改html数据,怎么修改网页数据
- google翻译的一个错误
- uniapp 实时定位(系统、后台运行、支持息屏)插件 Ba-Location
- 深入Python 验证码解析
- Matlab统计图片中不同颜色小球个数