CodeForces
来源:互联网 发布:软件架构设计实例 编辑:程序博客网 时间:2024/05/16 11:12
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.
#include<stdio.h>int main(){ int n,k; while(scanf("%d%d",&n,&k)!=EOF) { if(3*n<=k) printf("%d\n",0); else printf("%d\n",n-(k-2*n)); }}
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 域名来路判断
- List
- java redirect跳转
- String字符串的拼接问题
- java static
- CodeForces
- 新浪初见
- 从 ECMAScript 规范来看 JS 的 this 绑定规则
- 基于opencv的身份证识别系统
- JVM参数优化JAVA_OPTS
- android studio 快捷键(eclipse版)--部分
- JAVA三大框架的各自作用
- mysql中的触发器和存储过程的区别是什么?
- svn清理不掉的解决方法