Rahim is attending in a game. In this game he has to pick up N number of same color balls among some distinct colors of balls from a box blindly. The colors are red, blue, green and yellow. In that box there are respectively R, B, G and Y numbers of red, blue, green and yellow color balls. Input: ------ Input starts with an integer **T ( 1<=T<=10 )**, denoting the number of test cases.<br> Each case contains two lines of input. First line will contain four integers **R , B, G** and **Y ( 2 ≤ R, B, G, Y ≤ 10^9 )** denoting respectively the number of red, blue, green and yellow color balls. The next line will contain an integer **N ( 1 ≤ N ≤ min (R ,B, G, Y) )** denoting the number of same color balls which Rahim has to find out blindly. Output: ------- For each case of input, output will be an integer number representing the minimum number of balls Rahim has to pick up from the box blindly to ensure that **N** balls of same color. Sample Input ------------ 1 10 10 10 10 4 Sample Output ------------- 13

MD. ISHTIAQ ISLAM

Language |
Time Limit (seconds) |

C | 1.00 |

C++ | 1.00 |

C++14 | 1.00 |

C# | 2.00 |

Go | 2.00 |

Java | 2.00 |

JavaScript | 2.00 |

Objective-C | 2.00 |

Perl | 2.00 |

PHP | 2.00 |

Python | 2.00 |

Python3 | 2.00 |

Ruby | 2.00 |

VB.Net | 2.00 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | st3inum | Cpp14 | 0.00s |

02 | spectro30 | Cpp | 0.00s |

03 | Reayz | Cpp14 | 0.00s |

04 | DynamicOvi | Cpp | 0.00s |

05 | Arpan_cse_2k14 | Cpp | 0.00s |

06 | Essux | Cpp | 0.00s |

07 | Ahb_arif | Cpp | 0.00s |

08 | Masum_ice | Cpp | 0.00s |

09 | Hasinur_ | Cpp | 0.00s |

10 | m_arif | Cpp | 0.00s |

11 | subhashis_cse | Cpp | 0.00s |

12 | BlueOcean | Cpp | 0.00s |

13 | shahed95 | Cpp | 0.00s |

14 | loop_breaker | Cpp | 0.00s |

15 | Old_kernel | Cpp14 | 0.00s |

16 | muhaimin | Cpp | 0.00s |

17 | Tufahel | Cpp | 0.00s |

18 | ashraful_afruz | Cpp | 0.00s |

19 | Shadman_Ibne_Saiful | C | 0.00s |

20 | tfahim227007 | C | 0.00s |

21 | Maruf_Robin | Cpp | 0.00s |

22 | mash02 | Cpp | 0.00s |

23 | pulak_ict_mbstu | Cpp | 0.00s |

24 | asad_IT | Cpp | 0.00s |

25 | ssavi | Cpp | 0.00s |

26 | Mhkhaled | Cpp | 0.00s |

27 | daihan_mbstu | Cpp | 0.00s |

28 | Nuwaisir | Cpp | 0.00s |

29 | kashem1993 | Cpp | 0.00s |

30 | _Lucifer | Cpp14 | 0.00s |

31 | alamkhan | Cpp | 0.00s |

32 | 10102020 | Cpp | 0.00s |

33 | Ihtiaz | Cpp | 0.00s |

34 | motaleb_ICT | Cpp | 0.00s |

35 | fayedanik | Cpp | 0.00s |

36 | hamza133913 | Cpp | 0.00s |

37 | Mahadi_Hasan | Cpp | 0.00s |

38 | factoradic | Cpp14 | 0.00s |

39 | trafalgar_8 | C | 0.00s |

40 | sumaiya710 | Cpp | 0.00s |

41 | wizard | Cpp | 0.00s |

42 | Ratul728 | Cpp | 0.00s |

43 | Chayti_Saha98 | Cpp | 0.00s |

44 | Bappy | Cpp | 0.00s |

45 | Chucks | Cpp14 | 0.00s |

46 | Nasif_44th | C | 0.00s |

47 | dmehedi | Cpp14 | 0.00s |

48 | monir_18 | Cpp | 0.00s |

49 | ivax6 | Cpp14 | 0.00s |

50 | SMunira | C | 0.00s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(