February Cook-Off 2022 Division 4
Complete the credits
In Uttu's college, a semester is said to be a:
- Overload semester if the number of credits taken .
- Underload semester if the number of credits taken .
- Normal semester otherwise
Given the number of credits taken by Uttu, determine whether the semester is Overload, Underload or Normal.
Input Format
- The first line will contain - the number of test cases. Then the test cases follow.
- The first and only of each test case contains a single integer - the number of credits taken by Uttu.
You may print each character of Overload, Underload and Normal in uppercase or lowercase (for example, ovErLoAd, oVERlOAD, OVERLOAD will be considered identical).
Output Format
For each test case, output Overload, Underload or Normal depending upon the number of credits taken by Uttu.
Constraints
Sample Input 1
4
65
80
23
58
Sample Output 1
Normal
Overload
Underload
Normal#include <iostream>
using namespace std;
int main() {
int test;
cin>>test;
while(test--)
{ int c;
cin>>c;
if(c>65) cout<<"Overload"<<endl;
else if(c<35) cout<<"Underload"<<endl;
else cout<<"Normal"<<endl;
}
return 0;
}
Guess the bottom face
It is known that in regular dice, the sum of opposite faces is .
A regular dice is rolled and you are given the value showing on the top face. Determine the value on the bottom face.
Input Format
- The first line will contain - the number of test cases. Then the test cases follow.
- The first and only of each test case contains a single integer - the value on the top face.
Output Format
For each test case, output the value on the bottom face.
Constraints
Sample Input 1
3
3
1
6
Sample Output 1
4
6
1
Explanation
Test case-1: The value on the top face is . Therefore, the value on the bottom face is because .
Test case-2: The value on the top face is . Therefore, the value on the bottom face is because .
Test case-3: The value on the top face is . Therefore, the value on the bottom face is because .
#include <iostream>
using namespace std;
int main() {
int t,s;
cin>>t;
while(t--){
cin>>s;
cout<<7-s<<endl;
}
return 0;
}
Peaceful Party
The mayor of your city has decided to throw a party to gather the favour of his people in different regions of the city.
There are distinct regions in the city namely , , comprising of , and number of people respectively.
However, the mayor knows that people of the region are in conflict with people of regions and . So, there will be a conflict if people from region are present at the party along with people from region or .
The mayor wants to invite as many people as possible and also avoid any conflicts. Help him invite maximum number of people to the party.
Input Format
- The first line contains a single integer - the number of test cases. Then the test cases follow.
- The first line of each test case contains three integers , and - number of people living in regions , and respectively.
Output Format
For each test case, output the maximum number of people that can be invited to the party.
Constraints
Sample Input 1
3
2 3 4
1 5 2
8 8 8
Sample Output 1
6
5
16
Explanation
Test case-1: Mayor can invite all the people from region and . So the maximum number of people invited is .
Test case-2: Mayor can invite all the people from region . So the maximum number of people invited is .
Lazy Salesman
Ved is a salesman. He needs to earn at least rupees in days for his livelihood. However, on a given day (), he can only earn rupees by working on that day.
Ved, being a lazy salesman, wants to take as many holidays as possible. It is known that on a holiday, Ved does not work and thus does not earn anything. Help maximize the number of days on which Ved can take a holiday.
It is guaranteed that Ved can always earn at least rupees by working on all days.
Input Format
- The first line contains a single integer - the number of test cases. Then the test cases follow.
- The first line of each test case contains two integers and - the size of the array and the money Ved has to earn in those days.
- The second line of each test case contains space-separated integers denoting the money which Ved can earn on each day.
Output Format
For each test case, output the maximum number of holidays Ved can take.
Constraints
- It is guaranteed that Ved can always earn at least rupees by working on all days.
Sample Input 1
3
5 10
3 2 6 1 3
4 15
3 2 4 6
6 8
9 12 6 5 2 2
Sample Output 1
2
0
5
Explanation
Test case-1: Ved can work on -nd, -rd and -th day earning rupees rupees. Thus he can take holidays on the -st and the -th day.
Test case-2: Ved has to work on all days to earn rupees. Thus he can not take any holidays.
Test case-3: Ved can work on -nd day earning rupees rupees. Thus he can take holiday on the remaining days.
For More Check here : https://www.codechef.com/COOK138D