**Not a member of Pastebin yet?**

**, it unlocks many cool features!**

__Sign Up__- Mr. Stark is the owner of Stark industries, a manufacturer of weaponry.
- A local Mafia group has hijacked one of the factories in the desert.
- The mafias want to transport the weapons from the factory to their base camp, and use a single truck to do it.
- 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
- lose 1 weapon for every km travelled.
- The weapons can be unloaded at any point from the truck, and can be picked up again later.
- 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
- weapons that can be transferred intact from the factory to the mafia base.
- Function Description:
- findMaxWeapons function takes the following parameters:
- X - the number of weapons
- Y - max capacity of the truck
- Z - distance between the factory and the base
- The function should return an integer representing the maximum number of weapons that can be transferred intact from the factory to the mafia base.
- Constraints
- 0 <= X <= 10^19
- 0 <= Y <= 10^19
- 0 <= Z <= 10^19
- Sample testcase 1:
- Input:
- 500 ---> Number of weapons
- 1000 --> Max capacity of the truck
- 100 ---> Distance between the factory and the base.
- Output:
- 400 ---> maximum number of weapons that can be transferred intact.
- Sample testcase 2:
- Input:
- 200
- 100
- 125
- Output:
- 25

RAW Paste Data