A. Exams
来源:互联网 发布:linux 不能识别ttc字体 编辑:程序博客网 时间:2024/05/16 08:21
One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.
The author would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have spoilt the Codeforces round. On the other hand, if the sum of his marks is strictly less than k, the author's mum won't be pleased at all.
The Codeforces authors are very smart and they always get the mark they choose themselves. Also, the Codeforces authors just hate re-sitting exams.
Help the author and find the minimum number of exams he will have to re-sit if he passes the exams in the way that makes the sum of marks for all n exams equal exactly k.
The single input line contains space-separated integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 250) — the number of exams and the required sum of marks.
It is guaranteed that there exists a way to pass n exams in the way that makes the sum of marks equal exactly k.
Print the single number — the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal k.
4 8
4
4 10
2
1 3
0
In the first sample the author has to get a 2 for all his exams.
In the second sample he should get a 3 for two exams and a 2 for two more.
In the third sample he should get a 3 for one exam.
解题说明:题目中给出n场考试,每场考试得分为2-5分,问如何评分让总分等于k并且让得2分的考试最多。此题可以这样分析,如果每场考试都得3分,判断比k多多少,多的部分就是得2分的考试场次,当然肯定要大于0才行
#include<iostream>#include<map>#include<string>#include<algorithm>#include<cstdio>using namespace std;int main(){int n,k;scanf("%d %d",&n,&k);printf("%d\n",max(3*n-k,0));return 0;}
- A. Exams
- <cf>A. Exams
- CodeForces 194A Exams
- CodeForces 480A. Exams
- 【CODEFORCES】 A. Exams
- Exams
- MCSE Core Required Exams in a Nutshell
- A+, Network+, Security+ Exams in a Nutshell: A Desktop Quick Reference
- CompTIA A+ Exam Prep (Exams A+ Essentials, 220-602, 220-603, 220-604)
- Java Exams
- cf479C Exams
- C. Exams
- Codeforces732D Exams
- [CF480A]Exams
- Exams 二分法
- Exams CodeForces
- Preparing for final exams!!
- hp exams questions
- 基于mysql的搜索引擎 Sphinx
- T4模版在代码生成中的应用心得
- android 录音
- “no cuda-capable device is detected”问题解决方法
- 《大话设计模式》部分模式总结(二)
- A. Exams
- 你应该知道的10种软件工具
- 用EXCEL完成GPS坐标转换的简易方法
- 解决 PHP Mysql 和 UTF8的问题
- C#归并排序
- 在C++ 程序中调用被C编译器编译后的函数,为什么要加extern “C”?
- Android客户端与PC服务器实现Socket通信
- 免费的项目托管网站
- android中dip、dp、px、sp和屏幕密度