Art Installation
면접 대비시간 제한1초메모리 제한2048 MB
필요한 빨강, 초록, 파랑 LED 개수와 보유한 개수, 빨강이나 초록으로 쓸 수 있는 LED와 초록이나 파랑으로 쓸 수 있는 LED의 재고가 주어질 때, 설치를 끝내기 위해 사야 하는 특수 LED의 최소 개수를 구하거나 불가능하면 -1을 출력한다.
문제
Jolie is setting up an art installation for her cat, Millie. The art installation will be made up of multiple LEDs.
Jolie has decided that she needs a specific number of red LEDs, green LEDs, and blue LEDs. After rummaging through her desk, she has found some of each. She can buy two special types of LEDs, one which can be either red or green, and another which can be either green or blue.
How many of the special LEDs will Jolie need to buy to finish her installation?
입력
The first line of input contains three integers , and (), which are the numbers of red LEDs, green LEDs, and blue LEDs Jolie needs.
The second line contains three integers , and (), which are the numbers of red LEDs, green LEDs, and blue LEDs Jolie already owns.
The third line contains two integers and (), which are the numbers of special LEDs that can be either red or green, and the number of special LEDs that can be either green or blue, that are available for Jolie to buy.
출력
Output a single integer, which is the total number of LEDs Jolie needs to buy to make her installation. Output if there aren’t enough LEDs for her to complete her installation.