There has been a security breach in the Schöftung Universität in the peaceful Bavarian village of Körpergörper-am-Harlachinger-Quellbach. Thieves have found the secret vault holding the exam sheets and are busy making use of it. The headmaster, Trie von Apovberger is the only one left in the university. He is renowned for his mighty right hand and is standing at the entrance, slapping the pesky thieves. There are too many of them though.
Von Apovberger can only slap 5 thieves per escape attempt. The others manage to escape with the exam sheets. Hėr Apovberger also replenishes his strength by drinking beer. He is German so he drinks a lot of it. No beer can evade the stomach and kidneys of von Apovberger, so every single bottle is put to use.
Your task is to calculate the amount of thieves that are slapped, thieves that manage to escape, and beer drunk in amount of six-packs and remaining bottles.
Input
- On the first line you receive the number N – the number of escape attempts.
- On the next N * 2 lines, you receive two integers, each on a new line
- T – the amount of thieves that attempt to escape
- B – the amount of beer that von Apovberger drinks
Output
- On the first line, display the amount of thieves slapped, in format {count} thieves slapped.
- On the second line – the thieves that escaped, in format {count} thieves escaped.
- On the third line – the beer drunk, in format {count} packs, {count} bottles.
Constraints
- N is an integer in range [1 … 50]
- T and B are integers in range [1 … 231 - 1]
- Allowed memory: 16 MB
- Allowed time: 0.1s
Examples
Elegant and interesting task! It was a challange solving it! Thanks for sharing! Here's my solution:
using System; class GrandTheftExamo { static void Main() { int n = int.Parse(Console.ReadLine()); decimal[] inputArray = new decimal[n * 2]; for (int i = 0; i < n * 2; i++) { inputArray[i] = decimal.Parse(Console.ReadLine()); } decimal thievesAll = 0; decimal beersAll = 0; for (int i = 0; i < inputArray.Length; i++) { if (i % 2 == 0) { thievesAll += inputArray[i]; } else if (i % 2 != 0) { beersAll += inputArray[i]; } } if (thievesAll >= n * 5) { Console.WriteLine("{0} thieves slapped.", n * 5); Console.WriteLine("{0} thieves escaped.", thievesAll - n * 5); Console.WriteLine("{0} packs, {1} bottles.", Math.Floor(beersAll / 6), beersAll % 6); } else if (thievesAll < n * 5) { Console.WriteLine("{0} thieves slapped.", thievesAll); Console.WriteLine("{0} thieves escaped.", 0); Console.WriteLine("{0} packs, {1} bottles.", Math.Floor(beersAll / 6), beersAll % 6); } } }