Codeforces Round #456 (Div. 2) A. Tricky Alchemy
传送门: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.
解题心得:
- 很简单的一个模拟题,题意也很简单就不说了,在比赛的时候头脑发昏,居然用算出的和加起来去减给出的晶块数目的和,简直想砍掉自己的脑袋。
- 注意使用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的更多相关文章
- Codeforces Round #456 (Div. 2)
Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶, ...
- 【Codeforces Round #456 (Div. 2) A】Tricky Alchemy
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 统计需要的个数. 不够了,就买. [代码] #include <bits/stdc++.h> #define ll lo ...
- Codeforces Round #245 (Div. 1) 429D - Tricky Function 最近点对
D. Tricky Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/42 ...
- 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 ...
- Codeforces Round #456 (Div. 2) 912E E. Prime Gift
题 OvO http://codeforces.com/contest/912/problem/E 解 首先把这个数字拆成个子集,各自生成所有大小1e18及以下的积 对于最坏情况,即如下数据 16 2 ...
- Codeforces Round #456 (Div. 2) 912D D. Fishes
题: OvO http://codeforces.com/contest/912/problem/D 解: 枚举每一条鱼,每放一条鱼,必然放到最优的位置,而最优位置即使钓上的概率最大的位置,即最多的r ...
- 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 ...
- 【Codeforces Round #456 (Div. 2) B】New Year's Eve
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然10000..取到之后 再取一个01111..就能异或成最大的数字了. [代码] /* 1.Shoud it use long ...
- 【Codeforces Round #456 (Div. 2) C】Perun, Ult!
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] set1 < pair < int,int > > set1;记录关键点->某个人怪物永远打不死了,第 ...
随机推荐
- 批量 多个JPG生产PDF .net C#
using iTextSharp.text; using iTextSharp.text.pdf; using System; using System.Collections.Generic; us ...
- 《大话设计模式》num01---简单工厂模式
2017年12月10日 20:13:57 独行侠的守望 阅读数:128更多个人分类: 设计模式编辑版权声明:本文为博主原创文章,转载请注明文章链接. https://blog.csdn.net/xia ...
- hibernate课程 初探单表映射2-7 hbm配置文件常用设置
本节主要简介hbm配置文件以下内容: 1 mapping标签 2 class标签 3 id标签 1 hibbernate-mapping标签 schema 模式名称 catalog 目录名称 defa ...
- .Net Core+mySqlSugar的一些稍复杂操作
介绍一些我尝试的mysqlSugar的数据库操作 修改密码 var status = db.Update<Users>(new { password = user.password }, ...
- Jquery里面的$(this)和this, 有什么区别
当你用的是jquery时,就用$(this),如果是JS,就用this $(this).html( $(this).html() + " BAM! "); 这个里的html()是J ...
- Yii2 Working with Relational Data at ActiveDataProvider
Yii2 Working with Relational Data at ActiveDataProvider namespace common\models; use Yii; use yii\ba ...
- 利用binlog2sql解析mysqlbinlog row行日志
binlog2sql 项目作者:曹单锋 github项目地址:https://github.com/danfengcao/binlog2sql 也可在github.com上搜索“binlog2sql” ...
- 【BZOJ4571】[SCOI2016] 美味(主席树)
点此看题面 大致题意: 给你一个序列\(a\),然后每次询问\(max_{i=l}^r(a_i+x)\ xor\ b\). 大致思路 首先,我们要知道一个简单的性质:位运算时位与位之间是互不影响的. ...
- Python-Boolean operation
一.布尔运算符 1.x and y: if x is false, then x, else y 2.x or y: if x is false, then y, else x 3.not x: if ...
- sublime package control以及常用插件
一.package Control安装 1.sublime 3 import urllib.request,os; pf = 'Package Control.sublime-package'; ip ...