Advertisement
arvind_iyer_2001

Part C

Jun 21st, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def s_c():
  2.     n, k, x = tuple([int(x) for x in input().split()])
  3.     a = [int(x) for x in input().split()]
  4.     a.sort()
  5.     j = 0
  6.     count = k
  7.     d = []
  8.     for i in range(1,n):
  9.         c = a[i]- a[i-1]
  10.         if(c > x):
  11.             d.append((j,c // x))
  12.             j += 1
  13.     d.sort(key= lambda item: item[1])
  14.     print(j+1)
  15.     i = 0
  16.     while count > 0 and j != 0 and i < len(d):
  17.         if(count >= d[i][1]):
  18.             count -= d[i][1]
  19.             j -= 1
  20.         else:
  21.             break
  22.         i += 1
  23.     print(j + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement