CF912A Tricky Alchemy

Posted 一蓑烟雨任生平

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

 

 

以上是关于CF912A Tricky Alchemy的主要内容,如果未能解决你的问题,请参考以下文章

CF418E Tricky Password(未完待续)

Tricky Segmentation在C中以BST递归出错

Codeforces 429D Tricky Function 近期点对

安装了sql-alchemy但导入sql_alchemy时失败

如何使用 Alchemy 将 C++ 移植到 swf?

python 一些代码使用模式作为SQL-Alchemy的声明基础,以及对Celery分支的支持。