0
点赞
收藏
分享

微信扫一扫

Codeforces Round #456 Div.2 A. Tricky Alchemy

承蒙不弃 2022-08-04 阅读 46


Problem

​​http://codeforces.com/contest/912/problem/A​​

Analysis

One needs 2·x + y yellow and 3·z + y blue crystals. The answer therefore is max(0, 2·x + y - A) + max(0, 3·z + y - B).

Code

C++

#include <iostream>
using namespace std;

int main()
{
long long A, B;
long long x, y, z;
cin >> A >> B;
cin >> x >> y >> z;

long long yellow = 2 * x + y - A;
long long blue = y + 3 * z - B, 0LL;

cout << max(yellow, 0) + max(blue, 0);

return 0;
}

Python2

a, b = map(int, raw_input().split())
x, y, z = map(int, raw_input().split())

yellow = 2 * x + y
blue = y + 3 * z
ans = max(0, yellow - a) + max(0, blue - b)

print



举报

相关推荐

0 条评论