fork(2) download
  1. # otvet.mail.ru/question/220872266
  2. n, x = map(int, input().split())
  3.  
  4. a = list(map(int, input().split()))
  5. b = list(map(int, input().split()))
  6.  
  7. top = x
  8. top_buy = -1
  9. top_sell = -1
  10. m = 0
  11.  
  12. for i in range(n):
  13. h = x // a[i]
  14. o = x % a[i]
  15. if top_sell < i + 1:
  16. c = b[i:]
  17. m = max(c)
  18. top_sell_new = c.index(m) + i + 1
  19. if m * h + o > top:
  20. top = m * h + o
  21. top_buy = i + 1
  22. top_sell = top_sell_new
  23.  
  24. print(top)
  25. print(top_buy, top_sell)
Success #stdin #stdout 0.02s 9348KB
stdin
5 1000
2 3 1 4 3
1 2 1 2 3
stdout
3000
3 5