Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #!/bin/python
  2.  
  3. import math
  4. import os
  5. import random
  6. import re
  7. import sys
  8.  
  9. # Complete the minuteToWinIt function below.
  10. def minuteToWinIt(a, k, n):
  11.   valores = dict()
  12.   for i in range(0, n):
  13.     val = a[i] - k*i
  14.     if(val in valores):
  15.       valores[val] += 1
  16.     else:
  17.       valores[val] = 1
  18.  
  19.   max = 0
  20.   for values in valores:
  21.     if max < valores[values]:
  22.       max = valores[values]
  23.  
  24.   return (n - max)
  25.  
  26. if __name__ == '__main__':
  27.   fptr = open(os.environ['OUTPUT_PATH'], 'w')
  28.  
  29.   nk = raw_input().split()
  30.  
  31.   n = int(nk[0])
  32.  
  33.   k = int(nk[1])
  34.  
  35.   a = map(int, raw_input().rstrip().split())
  36.  
  37.   result = minuteToWinIt(a, k, n)
  38.  
  39.   fptr.write(str(result) + '\n')
  40.  
  41.   fptr.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement