304781: CF912A. Tricky Alchemy

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Tricky Alchemy

题意翻译

Grisha有一些水晶,可以用这些水晶造出一些水晶球。现在他有A个黄水晶,B个蓝水晶。现在他要造出x个黄水晶球,y个绿水晶球,z个蓝水晶球。请问他还额外需要几个水晶(不需要就输出0)才能完成任务。 > 2个黄水晶可造出1个黄水晶球 > 1个黄水晶加上1个蓝水晶可造出1个绿水晶球 > 3个蓝水晶可造出1个蓝水晶球

题目描述

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.

输入输出格式

输入格式


The first line features two integers $ A $ and $ B $ ( $ 0<=A,B<=10^{9} $ ), 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<=10^{9} $ ) — the respective amounts of yellow, green and blue balls to be obtained.

输出格式


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

输入输出样例

输入样例 #1

4 3
2 1 1

输出样例 #1

2

输入样例 #2

3 9
1 1 3

输出样例 #2

1

输入样例 #3

12345678 87654321
43043751 1000000000 53798715

输出样例 #3

2147483648

说明

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.

Input

题意翻译

Grisha有一些水晶,可以用这些水晶造出一些水晶球。现在他有A个黄水晶,B个蓝水晶。现在他要造出x个黄水晶球,y个绿水晶球,z个蓝水晶球。请问他还额外需要几个水晶(不需要就输出0)才能完成任务。 > 2个黄水晶可造出1个黄水晶球 > 1个黄水晶加上1个蓝水晶可造出1个绿水晶球 > 3个蓝水晶可造出1个蓝水晶球

加入题单

上一题 下一题 算法标签: