codeforces—— 439A —— Devu, the Singer and Churu, the Joker
来源:互联网 发布:mac bird进程 编辑:程序博客网 时间:2024/05/17 01:41
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 302 2 1
5
3 202 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.
输入n,m,然后输入n首歌唱一次的时间,两首之间要讲两个笑话,歌必须唱完,问最多几个笑话。
水题
#include<iostream>#include<cmath>#include<cstdio>#include<map>#include<set>#include<cstring>#include<string>#include<algorithm>#define min 1e-6using namespace std;int main(){ int n,m; while(cin>>n>>m) { int TIME=(n-1)*10,ans=(n-1)*2; while(n--) { int temp; cin>>temp; TIME+=temp; } if(TIME<=m) cout<<ans+(m-TIME)/5<<endl; else cout<<"-1"<<endl; } return 0;}
- codeforces—— 439A —— Devu, the Singer and Churu, the Joker
- Codeforces 439A Devu, the Singer and Churu, the Joker
- Codeforces 439 A. Devu, the Singer and Churu, the Joker
- Codeforces 439A Devu, the Singer and Churu, the Joker
- codeforces 439A Devu, the Singer and Churu, the Joker
- Codeforces Round #251(Div. 2) 439A. Devu, the Singer and Churu, the Joker 水题
- Devu, the Singer and Churu, the Joker
- A. Devu, the Singer and Churu, the Joker
- Codeforces 439A, the Singer and Churu, the Joker(水题)
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array(模拟)
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array 模拟
- Codeforces 439B Devu, the Dumb Guy
- Codeforces 439 B. Devu, the Dumb Guy
- CodeForces 439B Devu, the Dumb Guy
- CodeForces 439B Devu, the Dumb Guy
- 彻底删除系统自带的office2007
- linux常用命令汇总
- Range Addition II问题及解法
- C#中接口与抽象类的区别
- JeeSite 4.0 框架
- codeforces—— 439A —— Devu, the Singer and Churu, the Joker
- C语言中的static 详细分析
- mybits的批量化操作
- Ardupilot-copter-3.4.6版本编译
- HDU 6034 Balala Power! 2017多校1.2
- Java数据接口编写简单例子,Java Json解析,服务端接口输出Json数据,客户端通过HTTP获取接口Json数据
- 用PerformanceTiming来检测页面性能
- IntelliJ IDEA 如何查看maven 依赖树
- 7816通信的一些认识