Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- int[] bestBatch = new int[] { int.MinValue };
- string command = string.Empty;
- while ((command = Console.ReadLine()) != "Bake It!")
- {
- int[] currentBatch = command.Split('#').Select(int.Parse).ToArray();
- if (bestBatch.Sum() < currentBatch.Sum())
- {
- bestBatch = currentBatch;
- }
- else if (bestBatch.Sum() == currentBatch.Sum() &&
- bestBatch.Average() < currentBatch.Average())
- {
- bestBatch = currentBatch;
- }
- else if (bestBatch.Sum() == currentBatch.Sum() &&
- bestBatch.Average() == currentBatch.Average()&&
- bestBatch.Length>currentBatch.Length)
- {
- bestBatch = currentBatch;
- }
- }
- Console.WriteLine($"Best Batch quality: {bestBatch.Sum()}\n{string.Join(" ",bestBatch)}");
- }
- }
Add Comment
Please, Sign In to add comment