Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
For the upcoming semester, the admins of your university decided to keep a total of X seats for the MATH-1
course. A student interest survey was conducted by the admins and it was found that Y students were interested in taking up the MATH-1
course.
Find the minimum number of extra seats that the admins need to add into the MATH-1
course to make sure that every student who is interested in taking the course would be able to do so.
For each test case, output on a new line the minimum number of seats required to be added.
Input: 4
1 1
12 34
50 49
49 50
Output: 0
22
0
1
Test case 1: Exactly 1 seat is available for enrolment, and exactly 1 student is interested in taking up the course, hence addition of more seats is not required.
Test case 2: 12 seats are available for enrolment but 34 students are interested in taking up the course, hence the admins would have to add 34−12=22 more seats to make sure that every student interested in the course gets a seat.
Test case 3: 50 seats are available for enrolment and 49 students are interested in taking up the course, hence addition of more seats is not required.
Test case 4: 49 seats are available for enrolment, but 50 students are interested in taking up the course, hence the admins would have to add 50−49=1 more seat to make sure that every student interested in the course gets a seat.
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
if(x>=y)
cout<<0<<endl;
else
cout<<y-x<<endl;
}
return 0;
}
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
while(a-->0){
int x = sc.nextInt();
int y = sc.nextInt();
if(x >y){
System.out.println("0");
}
else{
System.out.println(y-x);
}
}
}
}
x = int(input())
for i in range(x):
a,b = map(int,input().split())
if(a > b):
print("0")
else:
print(b-a)
In our experience, we suggest you solve this MATH1 Enrolment CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the MATH1 Enrolment CodeChef Solution
I hope this MATH1 Enrolment CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>