Codeforces 439 A. 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<cstdio>
#define N 100 int t[N];
int main()
{
int d,n;
int Sum = ;
int count = ; scanf("%d%d",&n,&d);
for(int i=;i<=n;++i){
scanf("%d",&t[i]);
Sum += t[i];
}
Sum += (n-)*;
if(Sum > d)
printf("-1\n");
else
{
count += (n-)*;
printf("%d\n",count+(d-Sum)/);
}
int a;scanf("%d\n",&a);
return ;
}
Codeforces 439 A. Devu, the Singer and Churu, the Joker的更多相关文章
- Codeforces Round #251 (Div. 2) A - Devu, the Singer and Churu, the Joker
水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...
- codeforces 439 E. Devu and Birthday Celebration 组合数学 容斥定理
题意: q个询问,每一个询问给出2个数sum,n 1 <= q <= 10^5, 1 <= n <= sum <= 10^5 对于每一个询问,求满足下列条件的数组的方案数 ...
- codeforces#439 D. Devu and his Brother (二分)
题意:给出a数组和b数组,他们的长度最大1e5,元素范围是1到1e9,问你让a数组最小的数比b数组最大的数要大需要的最少改变次数是多少.每次改变可以让一个数加一或减一 分析:枚举a数组和b数组的所有的 ...
- Codeforces 493 E.Devu and Birthday Celebration
\(>Codeforces \space 493\ E.Devu\ and\ Birthday\ Celebration<\) 题目大意 : 有 \(q\) 组询问,每次有 \(n\) 小 ...
- Codeforces #439 Div2 E
#439 Div2 E 题意 给出二维平面,有多个询问: 把某一区域围起来(围墙之间无交点) 移除某一区域的围墙(此时保证围墙一定存在) 选定两个位置问是否可以互相到达 分析 看起来很复杂,其实这道题 ...
- Codeforces 451 E Devu and Flowers
Discription Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th ...
- 【Codeforces 258E】 Devu and Flowers
[题目链接] http://codeforces.com/contest/451/problem/E [算法] 容斥原理 [代码] #include<bits/stdc++.h> usin ...
- Codeforces 451 E. Devu and Flowers(组合数学,数论,容斥原理)
传送门 解题思路: 假如只有 s 束花束并且不考虑 f ,那么根据隔板法的可重复的情况时,这里的答案就是 假如说只有一个 f 受到限制,其不合法时一定是取了超过 f 的花束 那么根据组合数,我们仍然可 ...
- Codeforces Round 251 (Div. 2)
layout: post title: Codeforces Round 251 (Div. 2) author: "luowentaoaa" catalog: true tags ...
随机推荐
- C# 中关闭当前线程的四种方式 .
.net类库已经帮助我们实现了窗口的关闭,如果此窗口是系统的主窗口,关闭此窗口即应该退出了整个应用程序.但事实上有时候并不是这样的,关闭窗口,只是停止了当前窗口的消息循环.系统主窗口,实质上是Main ...
- 51nod1046快速幂取余
给出3个正整数A B C,求A^B Mod C. 例如,3 5 8,3^5 Mod 8 = 3. Input 3个正整数A B C,中间用空格分隔.(1 <= A,B,C <= 10^ ...
- 使用ECLIPSE+MINGW搭建C/C++开发环境
有个朋友要我帮忙跑一个C程序而我现在主要用java,电脑上也就没有C语言的编译和开发环境,在学习java的这段期间,接触到了Eclipse这个强大的IDE,用惯了.就为调试一个程序,去安装一个VS觉得 ...
- java 中的 & | ~ ^ 运算符分析
1.与运算符与运算符用符号“&”表示,其使用规律如下:两个操作数中位都为1,结果才为1,否则结果为0,例如下面的程序段.public class data13{public static vo ...
- C#中日期时间的简单操作
(1).比较2个DateTime的大小 DateTime dt1 = Convert.ToDateTime("2010/11/25 20:53:43"); DateTime dt2 ...
- Java学习--Equals与“==”
在Java规范中,它对equals()方法的使用必须要遵循如下几个规则: equals 方法在非空对象引用上实现相等关系: 1.自反性:对于任何非空引用值 x,x.equals(x) 都应返回 tru ...
- navigationController Pop回指定页面
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIn ...
- 【软件分享】文本对比工具 Beyond Compare
转载自公众号:EmbeddDeveloper 对嵌入式感兴趣可以关注原作者博客: http://blog.csdn.net/ybhuangfugui 此处转载为分享用 Ⅰ.摘要 Beyond Comp ...
- MongoDB 覆盖索引查询
MongoDB 覆盖索引查询 官方的MongoDB的文档中说明,覆盖查询是以下的查询: 所有的查询字段是索引的一部分 所有的查询返回字段在同一个索引中 由于所有出现在查询中的字段是索引的一部分, Mo ...
- js和Jquery获取选中select值和文本
<body> <select name="PaymentType" style="width:110px" > <option v ...