---
# System prepended metadata

title: 2739. Total Distance Traveled
tags: [Leetcode, Easy, Math]

---

Link: https://leetcode.com/problems/total-distance-traveled/description/
## 思路
第一次transfer 需要用掉mainTank里的5
之后的每次transfer 都只需要用mainTank里的4 因为additionalTank会transfer1过去
所以transfer的次数就是```min(additionalTank, (mainTank-1)//4)```
## Code
```python=
class Solution:
    def distanceTraveled(self, mainTank: int, additionalTank: int) -> int:
        return 10*(mainTank+min(additionalTank, (mainTank-1)//4))
```