nikolayneykov

Untitled

Mar 9th, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6.     static void Main(string[] args)
  7.     {
  8.         int[] bestBatch = new int[] { int.MinValue };
  9.  
  10.         string command = string.Empty;
  11.  
  12.         while ((command = Console.ReadLine()) != "Bake It!")
  13.         {
  14.             int[] currentBatch = command.Split('#').Select(int.Parse).ToArray();
  15.  
  16.             if (bestBatch.Sum() < currentBatch.Sum())
  17.             {
  18.                 bestBatch = currentBatch;
  19.             }
  20.             else if (bestBatch.Sum() == currentBatch.Sum() &&
  21.                 bestBatch.Average() < currentBatch.Average())
  22.             {
  23.                 bestBatch = currentBatch;
  24.             }
  25.             else if (bestBatch.Sum() == currentBatch.Sum() &&
  26.                 bestBatch.Average() == currentBatch.Average()&&
  27.                 bestBatch.Length>currentBatch.Length)
  28.             {
  29.                 bestBatch = currentBatch;
  30.             }
  31.         }
  32.  
  33.         Console.WriteLine($"Best Batch quality: {bestBatch.Sum()}\n{string.Join(" ",bestBatch)}");
  34.     }
  35. }
Add Comment
Please, Sign In to add comment