/63B.py

https://bitbucket.org/alculquicondor/codeforces · Python · 14 lines · 14 code · 0 blank · 0 comment · 5 complexity · 39b027180ef67a217044a5d3d81a2bf7 MD5 · raw file

  1. s=raw_input().split()
  2. n=int(s[0])
  3. k=int(s[1])
  4. A=[0]*(k+1)
  5. for x in [int(j) for j in raw_input().split()]:
  6. A[x]+=1
  7. r=0
  8. while A[k]!=n:
  9. r+=1
  10. for i in range(k-1,0,-1):
  11. if(A[i]>0):
  12. A[i]-=1
  13. A[i+1]+=1
  14. print r