Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. # 5 2 10
  2. # 5
  3. # 5
  4. # 3
  5. # 1
  6. # 4
  7.  
  8. inin = input().rstrip().split(' ')
  9. sakana, poi, Durability = int(inin[0]), int(inin[1]), int(inin[2])
  10.  
  11. d = Durability
  12. count = 0
  13.  
  14. def check(d, w, count, poi):
  15. if d > w:
  16. count += 1
  17. d = d - w
  18. else:
  19. poi -= 1
  20. if poi > 0:
  21. d = Durability
  22. check(d, w, count, poi)
  23.  
  24. for _ in range(sakana):
  25. w = int(input())
  26.  
  27. try:
  28. check(d, w, count, poi)
  29. except RecursionError:
  30. break
  31.  
  32. print(count)
  33.  
  34. inin = input().rstrip().split(' ')
  35. sakana, poi, Durability = int(inin[0]), int(inin[1]), int(inin[2])
  36.  
  37. d = Durability
  38. count = 0
  39.  
  40. def check(d, w, poi): # パラメータ削除
  41. global count # global変数を使う
  42.  
  43. if d > w:
  44. count += 1
  45. d = d - w
  46. else:
  47. poi -= 1
  48. if poi > 0:
  49. d = Durability
  50. check(d, w, poi) # パラメータ削除
  51.  
  52. for _ in range(sakana):
  53. w = int(input())
  54.  
  55. try:
  56. check(d, w, poi) # パラメータ削除
  57. except RecursionError:
  58. break
  59.  
  60. print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement