# PROBLEM LINK:

Contest Division 1

Contest Division 2

Contest Division 3

Contest Division 4

Practice

**Setter:** Anish Ashish Kasegaonkar

**Testers:** Nishank Suresh and Abhinav Sharma

**Editorialist:** Anish Ashish Kasegaonkar

# DIFFICULTY

349

# PREREQUISITES

None

# PROBLEM

There are a total of X seats available for enrolment for `MATH-1`

, and there are Y students who are interested in taking up the course. You have to output the minimum number of seats that need to be added to make sure that every interested student gets a seat.

# EXPLANATION

The solution can be divided into two cases:

- X\geq Y: In this case, there are more seats available than there are interested students (in the case of X=Y, there are exactly as many seats), hence no more seats need to be added. The answer for this case would be 0.
- X<Y: In this case, there are lesser seats available than there are interested students. Hence we would need to add some more seats, and this number is given by the current number of seats subtracted from the required number of seats (number of interested students), i.e. the answer for this case would be Y-X.

This will simplify to simply printing max(0, Y-X).

# TIME COMPLEXITY

The time complexity is O(1) per test case.

# SOLUTION

## Editorialist's Solution

```
// Anish Kasegaonkar
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
for (int i = 1; i <= t; ++i)
{
int x, y;
cin >> x >> y;
cout << max(0, y - x) << '\n';
}
return 0;
}
```