Guest User

Untitled

a guest
Aug 17th, 2019
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. Mr. Stark is the owner of Stark industries, a manufacturer of weaponry.
  2. A local Mafia group has hijacked one of the factories in the desert.
  3. The mafias want to transport the weapons from the factory to their base camp, and use a single truck to do it.
  4. But, every kilometer the truck travels with the weapons, one weapon falls off and breaks. The truck can only travel integral values of distance, and will
  5. lose 1 weapon for every km travelled.
  6. The weapons can be unloaded at any point from the truck, and can be picked up again later.
  7. Given the number of weapons X, max capacity of the truck Y and distance between the factory and the base Z, find the maximum number of
  8. weapons that can be transferred intact from the factory to the mafia base.
  9.  
  10.  
  11. Function Description:
  12. findMaxWeapons function takes the following parameters:
  13. X - the number of weapons
  14. Y - max capacity of the truck
  15. Z - distance between the factory and the base
  16. The function should return an integer representing the maximum number of weapons that can be transferred intact from the factory to the mafia base.
  17.  
  18.  
  19. Constraints
  20. 0 <= X <= 10^19
  21. 0 <= Y <= 10^19
  22. 0 <= Z <= 10^19
  23.  
  24.  
  25. Sample testcase 1:
  26. Input:
  27. 500 ---> Number of weapons
  28. 1000 --> Max capacity of the truck
  29. 100 ---> Distance between the factory and the base.
  30. Output:
  31. 400 ---> maximum number of weapons that can be transferred intact.
  32.  
  33.  
  34. Sample testcase 2:
  35. Input:
  36. 200
  37. 100
  38. 125
  39. Output:
  40. 25
Add Comment
Please, Sign In to add comment