传送门:http://codeforces.com/contest/912/problem/A

A. Tricky Alchemy

time limit per test1 second

memory limit per test256 megabytes

Problem Description

During the winter holidays, the demand for Christmas balls is exceptionally high. Since it’s already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.

Grisha needs to obtain some yellow, green and blue balls. It’s known that to produce a yellow ball one needs two yellow crystals, green — one yellow and one blue, and for a blue ball, three blue crystals are enough.

Right now there are A yellow and B blue crystals in Grisha’s disposal. Find out how many additional crystals he should acquire in order to produce the required number of balls.

Input

The first line features two integers A and B (0 ≤ A, B ≤ 109), denoting the number of yellow and blue crystals respectively at Grisha’s disposal.

The next line contains three integers x, y and z (0 ≤ x, y, z ≤ 109) — the respective amounts of yellow, green and blue balls to be obtained.

Output

Print a single integer — the minimum number of crystals that Grisha should acquire in addition.

Examples

input

4 3

2 1 1

output

2

input

3 9

1 1 3

output

1

input

12345678 87654321

43043751 1000000000 53798715

output

2147483648

Note

In the first sample case, Grisha needs five yellow and four blue crystals to create two yellow balls, one green ball, and one blue ball. To do that, Grisha needs to obtain two additional crystals: one yellow and one blue.


解题心得:

  1. 很简单的一个模拟题,题意也很简单就不说了,在比赛的时候头脑发昏,居然用算出的和加起来去减给出的晶块数目的和,简直想砍掉自己的脑袋。
  2. 注意使用long long数据量有点大。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll; int main()
{
ll a,b,x1,x2,x3;
scanf("%lld%lld%lld%lld%lld",&a,&b,&x1,&x2,&x3);
ll y1,y2;
y1 = y2 = 0;//记录需要使用的晶块的数量 y1 += x1*2;
y2 += x2;
y1 += x2;
y2 += x3*3; ll ans = 0;
if(y1 > a)
ans += y1-a;
if(y2 > b)
ans += y2-b;
printf("%lld",ans);
return 0;
}

Codeforces Round #456 (Div. 2) A. Tricky Alchemy的更多相关文章

  1. Codeforces Round #456 (Div. 2)

    Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶, ...

  2. 【Codeforces Round #456 (Div. 2) A】Tricky Alchemy

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 统计需要的个数. 不够了,就买. [代码] #include <bits/stdc++.h> #define ll lo ...

  3. Codeforces Round #245 (Div. 1) 429D - Tricky Function 最近点对

    D. Tricky Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/42 ...

  4. Codeforces Round #456 (Div. 2) B. New Year's Eve

    传送门:http://codeforces.com/contest/912/problem/B B. New Year's Eve time limit per test1 second memory ...

  5. Codeforces Round #456 (Div. 2) 912E E. Prime Gift

    题 OvO http://codeforces.com/contest/912/problem/E 解 首先把这个数字拆成个子集,各自生成所有大小1e18及以下的积 对于最坏情况,即如下数据 16 2 ...

  6. Codeforces Round #456 (Div. 2) 912D D. Fishes

    题: OvO http://codeforces.com/contest/912/problem/D 解: 枚举每一条鱼,每放一条鱼,必然放到最优的位置,而最优位置即使钓上的概率最大的位置,即最多的r ...

  7. Codeforces Round #456 (Div. 2) B. New Year's Eve

    B. New Year's Eve time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  8. 【Codeforces Round #456 (Div. 2) B】New Year's Eve

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然10000..取到之后 再取一个01111..就能异或成最大的数字了. [代码] /* 1.Shoud it use long ...

  9. 【Codeforces Round #456 (Div. 2) C】Perun, Ult!

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] set1 < pair < int,int > > set1;记录关键点->某个人怪物永远打不死了,第 ...

随机推荐

  1. matlab 常用函数(数学建模-复习)

    常用函数 fscanf(fid, '%c', inf) -> 直接读取整个文件, 因为inf表示无穷 strtrim char(num): 将num转为ASCII字符 strtok(conten ...

  2. jquery调用asp.net 页面后台的实现代码

    先创建一个aspx页面编写一个客户端控件<input type="button" id="AjaxDemo" value="AjaxDemo&q ...

  3. vs2013安装时提示核心功能错误

    VS核心功能安装时发生严重错误:解决办法:计算机管理->设备管理器->非即插即用驱动程序->http改为自动.

  4. 1074 食物链 2001年NOI全国竞赛

    1074 食物链 2001年NOI全国竞赛 时间限制: 3 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond         题目描述 Description 动物王国中有三类动物 ...

  5. 自定义列表dl

    语法格式 <dl> <dt>名词1</dt> <dd>名词1解释1</dd> <dd>名词1解释2</dd> ... ...

  6. vue+element-ui实现cookie登录

    //效果 //login.vue <template> <div> <el-form :model="ruleForm" :rules="r ...

  7. app开发,H5+CSS3页面布局小tips

    1.inline-block使用后带来的间隔影响 2.竖线的处理 3.ssh公匙 4.星星组件的巧妙用法 5.api.js的$api对象与 安卓原生引擎的api对象,均相当于jQuery的$对象 6. ...

  8. linux中BASH_SOURCE[0](转)

    转自:http://www.cnblogs.com/sunfie/p/5943979.html 在C/C++中,__FUNCTION__常量记录当前函数的名称.有时候,在日志输出的时候包含这些信息是非 ...

  9. 【文件拷贝】使用Total Commander Portable拖动拷贝文件,支持队列

    使用Total Commander Portable,可以批量拷贝多个位于相同或不同目录的文件(夹)到指定的相同或不同的目录.这样避免了同时复制多个大的文件造成的速度减慢:将所有任务手动操作之后,剩下 ...

  10. [习题] FindControl 简单练习--GridView + CheckBox,点选多列数据(复选删除)#3 List或数组

    [习题] FindControl 简单练习--GridView + CheckBox,点选多列数据(复选删除)#3 List或数组 之前的范例,使用字符串.文字来记录将删除的文章ID 后续会有很多小缺 ...