Monday, October 16, 2017

862 A. Mahmoud and Ehab and the MEX Codeforces Problem Solution

http://codeforces.com/problemset/problem/862/A

using System;

 class Program
{
     static void Main()
    {
        string s = Console.ReadLine();
        string[] values = s.Split(' ');
        int a = int.Parse(values[0]);
        int b = int.Parse(values[1]);
        string q = Console.ReadLine();
        string[] k = q.Split(' ');
         bool joy=false;
         int count=0;
        for(int i=0;i<a;i++)
        {
            if(int.Parse(k[i])<b)
            {
                count++;
            }
            if(int.Parse(k[i])==b)
            {
                joy=true;
            }
        }

         if(joy==true)
         {
             Console.WriteLine(b-count+1);
         }
         else
         {
             Console.WriteLine(b-count);
         }
    }
  
}

No comments:

Post a Comment