Guest User

Untitled

a guest
Mar 2nd, 2019
134
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Problem 3. Cooking Factory
  2. The George`s Cooking factory got another order. But this time you are tasked to bake
  3. the best Bread for a special party.
  4. Until you receive a command "Bake it!" you will be receiving strings, the batches of bread. Each string is an array of numbers, split by "#". Each element is a bread and the number represent its quality.
  5. You should select the batch with the highest total quality of bread.
  6. If there are several batches with same total quality select the batch with the greater average quality.
  7. If there are several batches with same total quality and average quality, take the one with the fewest elements (length).
  8. Input / Constraints
  9. • Until you receive a command "Bake it!" you will be receiving strings, the batches of bread. Each string is an array of numbers, split by "#". Each element is a bread and the number represent its quality.
  10. • Each batch will have from 1 to 10 elements.
  11. • Bread quality is an integer in the range [-100, 100].
  12. Output
  13. • After you receive the last command "Bake It!" you should print the following message:
  14. "Best Batch quality: {bestTotalQuality}"
  15. "{bread batch, joined by space}"
  16. Examples
  17. Input Output Comments
  18.  
  19. 5#4#10#-2
  20. 10#5#2#3#2
  21. Bake It! Best Batch quality: 22
  22. 10 5 2 3 2 We receive 2 batches, but the second is printed, because its total quality is better.
  23.  
  24. Input Output Comments
  25.  
  26. 5#3#2
  27. 10#2#-2#1#-1
  28. 4#2#1
  29. Bake It! Best Batch quality: 10
  30. 5 3 2 We receive 3 sequences. Both 1 and 2 have same total quality -> 10, but the first is printed, because its has better average quality 3.(333).
RAW Paste Data