Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Rabbits
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class ColouredBunniesCount
- {
- public static void Main()
- {
- int[] replies = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- var colourGroupsCount = new Dictionary<int, int>();
- var minBunnies = 0;
- foreach (var reply in replies)
- {
- int colourGroup = reply + 1;
- if (colourGroupsCount.ContainsKey(colourGroup))
- {
- colourGroupsCount[colourGroup]++;
- }
- else
- {
- colourGroupsCount.Add(colourGroup, 1);
- }
- }
- foreach (var pair in colourGroupsCount)
- {
- if (pair.Key > pair.Value)
- {
- minBunnies += pair.Key;
- }
- else
- {
- minBunnies += (int)Math.Ceiling((double)pair.Value / (pair.Key)) * (pair.Key);
- }
- }
- Console.WriteLine(minBunnies);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement