CF912A 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 20182018 , 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 AA yellow and BB 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 AA and BB ( 0<=A,B<=10^{9}0<=A,B<=109 ), denoting the number of yellow and blue crystals respectively at Grisha's disposal.

The next line contains three integers xx , yy and zz ( 0<=x,y,z<=10^{9}0<=x,y,z<=109 ) — 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.

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long a,b,x,y,z;
long long ans,sum1,sum2;
int main(){
    cin>>a>>b;
    cin>>x>>y>>z;
    sum1+=x*2;sum1+=y;
    sum2+=y;sum2+=z*3;
    ans+=(sum1-a)>0?sum1-a:0;
    ans+=(sum2-b)>0?sum2-b:0;
    cout<<ans;
}
细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
原文地址:https://www.cnblogs.com/cangT-Tlan/p/8443604.html