Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Contest76Task2Chocolates
- {
- static void Main()
- {
- string[] firstLineInput = Console.ReadLine().Split(' ');
- string[] secondLineInput = Console.ReadLine().Split(' ');
- int numberOfNumbers = int.Parse(firstLineInput[0]);
- int numberOfDifferent = int.Parse(firstLineInput[1]);
- int tempLong = 0;
- int tempDifferent = 0;
- int minLength = int.MaxValue;
- bool tempCheck = false;
- string[] tempDifferentNumbers = new string[numberOfDifferent];
- for (int i = 0; i < numberOfNumbers - (numberOfDifferent - 1); i++)
- {
- if (minLength == numberOfDifferent)
- {
- break;
- }
- if (secondLineInput[i] == secondLineInput[i + 1])
- {
- continue;
- }
- tempLong = 0;
- tempDifferent = 0;
- tempDifferentNumbers = new string[numberOfDifferent];
- for (int x = i; x <= numberOfNumbers; x++)
- {
- tempCheck = false;
- if (tempDifferent == numberOfDifferent)
- {
- if (tempLong < minLength)
- {
- minLength = tempLong;
- }
- break;
- }
- else if (x != numberOfNumbers)
- {
- tempLong++;
- for (int y = 0; y < numberOfDifferent; y++)
- {
- if (secondLineInput[x] == tempDifferentNumbers[y])
- {
- tempCheck = true;
- break;
- }
- }
- if (!tempCheck)
- {
- tempDifferentNumbers[tempDifferent] = secondLineInput[x];
- tempDifferent++;
- }
- }
- }
- }
- Console.WriteLine(minLength);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement