#ARC142E. [ARC142E] Pairing Wizards
[ARC142E] Pairing Wizards
Score : points
Problem Statement
There are wizards, numbered . Wizard has a strength of and plans to defeat a monster with a strength of .
You can perform the following operation any number of times.
- Increase the strength of any wizard of your choice by .
A pair of Wizard and Wizard (let us call this pair ) is said to be good when at least one of the following conditions is satisfied.
- Wizard has a strength of at least and Wizard has a strength of at least .
- Wizard has a strength of at least and Wizard has a strength of at least .
Your objective is to make the pair good for every . Find the minimum number of operations needed to achieve it.
Constraints
- , if .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
You can perform the operation once for Wizard and once for Wizard to achieve the objective with the fewest operations.
No operation is needed.