Problem A
Art Installation
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?
Input
The first line of input contains three integers $r$, $g$ and $b$ ($0 \le r,g,b \le 1\, 000$), which are the numbers of red LEDs, green LEDs, and blue LEDs Jolie needs.
The second line contains three integers $c_r$, $c_g$ and $c_b$ ($0 \le c_r,c_g,c_b \le 1\, 000$), which are the numbers of red LEDs, green LEDs, and blue LEDs Jolie already owns.
The third line contains two integers $c_{rg}$ and $c_{gb}$ ($0 \le c_{rg},c_{gb} \le 2\, 000$), 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
Output a single integer, which is the total number of LEDs Jolie needs to buy to make her installation. Output $-1$ if there aren’t enough LEDs for her to complete her installation.
Sample Input 1 | Sample Output 1 |
---|---|
583 290 710 396 65 796 309 800 |
412 |