PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/63B.py

https://bitbucket.org/alculquicondor/codeforces
Python | 14 lines | 14 code | 0 blank | 0 comment | 5 complexity | 39b027180ef67a217044a5d3d81a2bf7 MD5 | raw file
 1s=raw_input().split()
 2n=int(s[0])
 3k=int(s[1])
 4A=[0]*(k+1)
 5for x in [int(j) for j in raw_input().split()]:
 6	A[x]+=1
 7r=0
 8while 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
14print r