Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Cooking_factory
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- int avQuality = 0;
- int maxQuality = int.MinValue;
- int maxAvQuality = int.MinValue;
- int bestBatchIndex = -1 ;
- int batchIndex = -1; ;
- int minLenght = 0;
- List<string> batches = new List<string>();
- while (command!="Bake it!")
- {
- int quality = 0;
- batchIndex++;
- batches.Add(command);
- string[] batchNumbers = command.Split('#').ToArray();
- for (int i = 0; i < batchNumbers.Length; i++)
- {
- quality += int.Parse(batchNumbers[i]);
- }
- avQuality = quality / batchNumbers.Length;
- if (quality>maxQuality)
- {
- maxQuality = quality;
- bestBatchIndex = batchIndex;
- minLenght = batchNumbers.Length;
- maxAvQuality = avQuality;
- }
- else if(quality==maxQuality)
- {
- if(avQuality>maxAvQuality)
- {
- maxAvQuality = avQuality;
- bestBatchIndex = batchIndex;
- minLenght = batchNumbers.Length;
- }
- else if(avQuality==maxAvQuality)
- {
- if(batchNumbers.Length<minLenght)
- {
- maxAvQuality = avQuality;
- bestBatchIndex = batchIndex;
- minLenght = batchNumbers.Length;
- }
- }
- }
- command = Console.ReadLine();
- }
- string[] bestBatchNumbers = batches[bestBatchIndex].Split('#').ToArray();
- Console.WriteLine($"Best Batch quality: {maxQuality}");
- Console.WriteLine(string.Join(" ",bestBatchNumbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement