CHESSWIN - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

You’re playing a chess match against magnus. Currently, you’ve won A games and he’s won B. It’s known that A \lt B.
What’s the minimum number of games you need to play to at least give yourself a chance of winning the match?

EXPLANATION:

In the best case scenario, you win every remaining game and Magnus doesn’t win anything.
This means Magnus’ final score will remain B, while yours must be something larger than B to take the victory.

Since you want to minimize the number of games played, it’s best if you end up with B+1 victories.
You already have A, so (B+1)-A more games are needed.
The answer is hence

B+1-A

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
a, b = map(int, input().split())
print(b-a+1)