SHARE
TWEET

codeforces 1070/D

a guest Oct 20th, 2018 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bags = 0
  2. d = list(map(int, input().split()))
  3. n = d[0]
  4. k = d[1]
  5. a = list(map(int, input().split()))
  6. trashRn = a[0]
  7.  
  8.  
  9. for i in range(1, n):
  10.   trashRn += a[i]
  11.   remain = trashRn % k
  12.   bagsRn = trashRn // k
  13.   bags += bagsRn
  14.   trashRn %= k
  15.   if bagsRn == 0 and remain != 0: # meaning its 1 day old for sure
  16.     bags += 1
  17.     trashRn = 0
  18.  
  19. if remain != 0 and bagsRn != 0:
  20.   bags+=1
  21.  
  22. print(bags)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top