Codeforces Round #435 (Div. 2), problem: (A) Mahmoud and Ehab and the MEX

       

  1. import sys
  2. # sys.stdin = open('input.txt', 'r')
  3. # sys.stdout = open('output.txt', 'w')
  4. # sys.setrecursionlimit(1000000)
  5. def Ints(): return map(int, sys.stdin.readline().strip().split())
  6. def Strs(): return map(str, sys.stdin.readline().strip().split())
  7. def Array(): return list(map(int, sys.stdin.readline().strip().split()))
  8. def Str(): return sys.stdin.readline().strip()
  9. def Int(): return int(sys.stdin.readline().strip())
  10. def MOD(): return 1000000007
  11.  
  12. def power(base, power):
  13. MOD = 1000000007
  14. result = 1
  15. while power > 0:
  16. if power % 2 == 1:
  17. result = (result * base) % MOD
  18. power = power // 2
  19. base = (base * base) % MOD
  20. return result
  21.  
  22. if __name__ == "__main__":
  23. n , x = Ints()
  24. a = Array()
  25. sa = set(a)
  26.  
  27. count = 0
  28. for i in range(x):
  29. if i not in sa:
  30. count += 1
  31. if x in sa: count += 1
  32.  
  33. print(count)
  34.  

Comments

Popular Posts