양념 반 후라이드 반

2021. 4. 10. 13:22ssh$/알고리즘

https://www.acmicpc.net/problem/16917

 

Memo


  • 양념 1마리를 사는 경우보다 후라이드가 남더라도 반반 2마리를 사는게 싸다면 반반 두마리를 사도록 해야한다!

 

Code


제출 날짜

메모리

2016 KB

시간

0 ms

#include <iostream>
#include <vector>


int A, B, C, x, y, result;

void output()
{
	std::cout << result;
}

void solution()
{
	result = (C * 2 < A + B)
			 ? 2 * std::min(x, y) * C + (x - std::min(x, y)) * std::min(A, 2 * C) + (y - std::min(x, y)) * std::min(B, 2 * C) \
			 : result = x * A + y * B;

}

void input()
{
	std::cin >> A >> B >> C >> x >> y;
}

void preset()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
}

int main()
{
	preset();
	input();
	solution();
	output();
}

 

'ssh$ > 알고리즘' 카테고리의 다른 글

[C++] 2003 BOJ 수들의 합 2  (0) 2021.04.10
BOJ) 2193 이친수 <C++>  (0) 2021.01.27
BOJ) 1932 정수 삼각형 <C++>  (0) 2021.01.27
BOJ) 1149 RGB거리 <C++>  (0) 2021.01.24
BOJ) 11726 2xn 타일링 <C++>  (0) 2021.01.22