This is my 45 days of code challenge repository organize by Amity Coding Club that is official club of Amity University Gwalior
Please take a quick look at the contribution guidelines first. Thanks to all contributors; you rock!
After that, I will not update the readme file; I will just upload the programs to the C++ folder.
Tasks for Day 01:
Chef drank X ml of water today. Determine if Chef followed the doctor's advice or not.
Input Format
:
-
The first line contains a single integer T — the number of test cases. Then the test cases follow.
-
The first and only line of each test case contains one integer X — the amount of water Chef drank today.
Output Format
: -
For each test case, output YES if Chef followed the doctor's advice of drinking at least 2000 ml of water. Otherwise, output NO.
-
You may print each character of the string in uppercase or lowercase (for example, the strings YES, yEs, yes, and yeS will all be treated as identical).
Constraints
:
- 1 <= T <= 2000
- 1 <= X <= 4000
Explanation
:
Test case 1: Chef followed the doctor's advice since he drank 2999 ml of water which is >=2000 ml.
Test case 2: Chef did not follow the doctor's advice since he drank 1450 ml of water which is < 2000 ml.
Test case 3: Chef followed the doctor's advice since he drank 2000 ml of water which is >= 2000 ml.
For more details, You can find the full problem description on CodeChef's website: Water Consumption Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the Python
programming language:
T = int(input())
for _ in range(T):
X = int(input())
if X >= 2000:
print("YES")
else:
print("NO")
Tasks for Day 02:
- Chef has X 5 rupee coins and Y 10 rupee coins. Chef goes to a shop to buy chocolates for Chefina where each chocolate costs Z rupees. Find the maximum number of chocolates that Chef can buy for Chefina.
-
Input Format
:- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains three integers X, Y, and Z — the number of 5 rupee coins, the number of 10 rupee coins, and the cost of each chocolate.
-
Output Format
:- For each test case, output the maximum number of chocolates that Chef can buy for Chefina.
-
Constraints
:- 1 ≤ T ≤ 100
- 1 ≤ X, Y, Z ≤ 1000
-
Sample 1
:Input
Output
- 4
- 10 10 10
- 3 1 8
- 8 1 3
- 4 4 1000
Explanation
:- Test case 1: Chef has 10⋅5+10⋅10=150 rupees in total. Since each chocolate costs 10 rupees, Chef can spend all 150 rupees and buy 15 chocolates for Chefina.
- Test case 2: Chef has 3⋅5+1⋅10=25 rupees in total. Since each chocolate costs 8 rupees, Chef can buy a maximum of 3 chocolates for Chefina, leaving him with 1 rupee.
- Test case 3: Chef has 8⋅5+1⋅10=50 rupees in total. Since each chocolate costs 3 rupees, Chef can buy a maximum of 16 chocolates for Chefina, leaving him with 2 rupees.
- Test case 4: Chef has 4⋅5+4⋅10=60 rupees in total. Since each chocolate costs 1000 rupees, Chef can buy no chocolate for Chefina, leaving him with 60 rupees.
For more details, You can find the full problem description on CodeChef's website: Chef and Chocolates Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the Golang
programming language:
package main
import "fmt"
func main() {
var T, X, Y, Z int
fmt.Scan(&T)
for i := 0; i < T; i++ {
fmt.Scan(&X, &Y, &Z)
totalRupees := X*5 + Y*10
maxChocolates := totalRupees / Z
fmt.Println(maxChocolates)
}
}
Tasks for Day 03:
-
Problem
Chef's coding class is very famous in Chefland. This year X students joined his class, and each student will require one chair to sit on. Chef already has Y chairs in his class. Determine the minimum number of new chairs Chef must buy so that every student is able to get one chair to sit on.
-
Input Format
The first line contains a single integer T — the number of test cases. Then the test cases follow.
The first and only line of each test case contains two integers X and Y — the number of students in the class and the number of chairs Chef already has.
-
Output Format
For each test case, output the minimum number of extra chairs Chef must buy so that every student gets one chair.
-
Constraints
1 ≤ T ≤ 1000
0 ≤ X, Y ≤ 100
-
Sample 1:
-
Input
4
20 14
41 41
35 0
50 100
-
Output
6
0
35
0
-
Explanation
Test case 1: There are 20 students in the class, and Chef has 14 chairs already. Therefore Chef must buy 6 more chairs.
Test case 2: There are 41 students in the class, and Chef already has exactly 41 chairs. Therefore Chef does not need to buy any more chairs.
Test case 3: There are 35 students in the class, and Chef has no chairs initially. Therefore Chef must buy 35 chairs.
-
Input
For more details, You can find the full problem description on CodeChef's website: Chairs Requirement Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the JavaScript
programming language:
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let T;
let testCases = [];
rl.question("", (t) => {
T = parseInt(t);
readInput();
});
function readInput() {
if (testCases.length < T) {
rl.question("", (input) => {
const [X, Y] = input.split(" ").map(Number);
testCases.push({ X, Y });
readInput();
});
} else {
processInput();
}
}
function processInput() {
for (let i = 0; i < T; i++) {
const { X, Y } = testCases[i];
const extraChairs = Math.max(0, X - Y);
console.log(extraChairs);
}
rl.close();
}
Today's Beginner problem:
- Chef has started working at the candy store. The store has 100 chocolates in total.
- Chef’s daily goal is to sell X chocolates. For each chocolate sold, he will get 1 rupee. However, if Chef exceeds his daily goal, he gets 2 rupees per chocolate for each extra chocolate.
- If Chef sells Y chocolates in a day, find the total amount he made.
-
Input Format
:- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two space-separated integers X and Y — the daily goal of Chef and the number of chocolates he actually sells.
-
Output Format
:- For each test case, output on a new line the total amount Chef made in a day.
-
Constraints
:- 1 ≤ T ≤ 100
- 1 ≤ X, Y ≤ 10
-
Sample 1:
-
Input
4
3 1
5 5
4 7
2 3
-
Output
1
5
10
4
-
Explanation
:Test case 1: Chef's daily goal was 3. Since he sold only 1 chocolate, he'll get only 1 rupee.
Test case 2: Chef's daily goal was 5. Since he sold 5 chocolates, he'll get 5 rupees.
Test case 3: Chef's daily goal was 4. Since he sold 7 chocolates, he'll get 4 rupees for the 4 chocolates as his daily goal and 2 rupees per chocolate for the extra 3 chocolates. The total amount he gets is 4 + 3 * 2 = 10.
Test case 4: Chef's daily goal was 2. Since he sold 3 chocolates, he'll get 2 rupees for the 2 chocolates as his daily goal and 2 rupees per chocolate for the extra 1 chocolate. The total amount he gets is 2 + 1 * 2 = 4.
-
For more details, You can find the full problem description on CodeChef's website: Candy Store Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the C++
programming language:
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int x, y;
cin >> x >> y;
if (x >= y) {
cout << y;
} else {
cout << x + 2 * (y - x);
}
cout << endl;
}
return 0;
}
Today's Intermediate problem:
- 1 ≤ 𝑇 ≤ 10,000
- 1 ≤ 𝐿 ≤ 1,000
- 1 ≤ 𝑉1 < 𝑉2 ≤ 1,000
5 10 2 3 10 2 4 15 3 5 8 1 20 14 5 6
0 1 1 6 -1
For more details, You can find the full problem description on CodeChef's website: Work Smarter, Not Harder Problem Description.
C++
Python
❌ JavaScript
❌ Golang
Here's an example of using the C++
programming language:
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
int t;
float L, v1, v2;
cin >> t;
while (t--) {
cin >> L >> v1 >> v2;
setprecision(3);
int t1 = ceil(L / v1);
int t2 = ceil(L / v2);
if (t1 > t2) {
if (t1 == t2 + 1)
cout << "0" << endl;
else
cout << t1 - t2 - 1 << endl;
} else if (t1 == t2)
cout << "-1" << endl;
}
return 0;
}
Today's Beginner problem:
- The first line will contain T, the number of test cases.
- Each test case contains a single line of input, an integer X, denoting the battery level of the phone.
- For each test case, output in a single line "Yes" if the battery level is 15% or below. Otherwise, print "No".
- 1 ≤ T ≤ 100
- 1 ≤ X ≤ 100
3 15 3 65
Yes Yes No
- Test Case 1: The battery level is 15%. Thus, it would show a battery low notification.
- Test Case 2: The battery level is 3%, which is less than 15%. Thus, it would show a battery low notification.
- Test Case 3: The battery level is 65%, which is greater than 15%. Thus, it would not show a battery low notification.
For more details, You can find the full problem description on CodeChef's website: Battery Low Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the Python
programming language:
t = int(input())
for _ in range(t):
x = int(input())
if x <= 15:
print("Yes")
else:
print("No")
Today's Intermediate problem:
- The first line contains an integer T, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, a single integer N.
- For each testcase, output in a single line the answer to the problem.
- 1 ≤ T ≤ 10^5
- 1 ≤ N < 2 * 10^5 (N is odd)
2 1 3
1 2
- Test Case 1: Since there is only 1 hoop, that's the only one to be jumped into.
- Test Case 2: The first player jumps into hoop 1. The second player jumps into hoop 3 and finally the first player jumps into hoop 2. Then the second player cannot make another jump, so the process stops.
For more details, You can find the full problem description on CodeChef's website: Hoop Jump Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the Python
programming language:
t = int(input())
for _ in range(t):
n = int(input())
print((n + 1) // 2)
Today's Beginner problem:
- The first line contains a single integer T, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, a single integer N - denoting the number of friends.
- For each test case, output the minimum number of cars required to accommodate all the friends.
- 1 ≤ T ≤ 1000
- 2 ≤ N ≤ 1000
4 4 2 7 98
1 1 2 25
- Test Case 1: There are only 4 friends and a single car can accommodate 4 people. Thus, only 1 car is required.
- Test Case 2: There are only 2 friends and a single car can accommodate 4 people. Thus, only 1 car is required.
- Test Case 3: There are 7 friends and 2 cars can accommodate 8 people. Thus, 2 cars are required.
For more details, You can find the full problem description on CodeChef's website: Minimum Cars required Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the Golang
programming language:
package main
import "fmt"
func main() {
var t int
fmt.Scan(&t)
for i := 0; i < t; i++ {
var n int
fmt.Scan(&n)
fmt.Println((n + 3) / 4)
}
}
Today's Intermediate problem:
- The first line contains an integer T, the number of test cases. The description of the T test cases follows.
- Each test case consists of two lines:
- The first line contains a single integer D, the number of digits in N.
- The second line consists of a string of length D, the number N (in decimal representation). It is guaranteed that the string does not contain leading zeroes and consists only of the characters 0, 1, ..., 9.
- For each test case, print "Yes" if it is possible to rearrange the digits of N so that it becomes a multiple of 5. Otherwise, print "No".
- 1 ≤ T ≤ 1000
- 1 ≤ D ≤ 1000
- 1 ≤ N < 10^1000
- Sum of D over all test cases ≤ 1000
3 3 115 3 103 3 119
Yes Yes No
- Test Case 1: The given number is already divisible by 5, therefore the answer is "Yes".
- Test Case 2: We can obtain 310 = 62 * 5 by rearranging the digits of 103, so the answer is "Yes".
- Test Case 3: The only numbers that can be obtained by rearranging the digits of 119 are {119, 191, 911}. None of these numbers are multiples of 5, so the answer is "No".
For more details, You can find the full problem description on CodeChef's website: Rearranging digits to get a multiple of 5 Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the JavaScript
programming language:
//❌
Today's Beginner problem:
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two space-separated integers X and Y — the following and follower count of an account, respectively.
- For each test case, output on a new line, YES, if the account is spam and NO otherwise.
- 1 ≤ T ≤ 100
- 1 ≤ X, Y ≤ 100
4 1 10 10 1 11 1 97 7
NO NO YES YES
- Test Case 1: The following count is 1 while the follower count is 10. Since the following count is not more than 10 times the follower count, the account is not spam.
- Test Case 2: The following count is 10 while the follower count is 1. Since the following count is not more than 10 times the follower count, the account is not spam.
- Test Case 3: The following count is 11 while the follower count is 1. Since the following count is more than 10 times the follower count, the account is spam.
- Test Case 4: The following count is 97 while the follower count is 7. Since the following count is more than 10 times the follower count, the account is spam.
For more details, You can find the full problem description on CodeChef's website: Instagram Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the C++
programming language:
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int x, y;
cin >> x >> y;
cout << ((x > 10 * y) ? "YES" : "NO") << endl;
}
return 0;
}
Today's Intermediate problem:
- The first line contains a single integer T, the number of test cases. Then the test cases follow.
- For each test case, the first line contains three integers PA, PB, and PC, representing the number of people living in regions A, B, and C, respectively.
- For each test case, output the maximum number of people that can be invited to the party without any conflicts.
- 1 ≤ T ≤ 1000
- 1 ≤ PA, PB, PC ≤ 1000
3 2 3 4 1 5 2 8 8 8
6 5 16
- Test Case 1: The mayor can invite all the people from regions A and C. So the maximum number of people invited is 6.
- Test Case 2: The mayor can invite all the people from region B. So the maximum number of people invited is 5.
- Test Case 3: The mayor can invite all the people from any one region without conflicts, so the maximum number of people invited is 16.
For more details, You can find the full problem description on CodeChef's website: Peaceful Party Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
//❌
Today's Beginner problem:
- The first line contains an integer T, the number of test cases. Then the test cases follow.
- Each test case consists of a single line of input with two integers X and Y, representing the capacity of the geyser and the bucket, respectively.
- For each test case, output the maximum number of people that can take a bath.
- 1 ≤ T ≤ 1000
- 1 ≤ X, Y ≤ 100
4 10 6 25 1 100 10 30 40
0 12 5 0
- Test Case 1: One bucket has a capacity of 6 litres. This means that one person requires 2 * 6 = 12 litres of water to take a bath. Since this is less than the total water present in the geyser, 0 people can take a bath.
- Test Case 2: One bucket has a capacity of 1 litre. This means that one person requires 2 * 1 = 2 litres of water to take a bath. The total amount of water present in the geyser is 25 litres. Thus, 12 people can take a bath. Note that 1 litre of water would remain unused in the geyser.
- Test Case 3: One bucket has a capacity of 10 litres. This means that one person requires 2 * 10 = 20 litres of water to take a bath. The total amount of water present in the geyser is 100 litres. Thus, 5 people can take a bath. Note that 0 litres of water would remain unused in the geyser after this.
For more details, You can find the full problem description on CodeChef's website: Bath in Winters Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the Golang
programming language:
package main
import "fmt"
func main() {
var T int
fmt.Scan(&T)
for i := 0; i < T; i++ {
var X, Y int
fmt.Scan(&X, &Y)
maxPeople := X / (2 * Y)
fmt.Println(maxPeople)
}
}
Today's Intermediate problem:
- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains two space-separated integers N and B.
- N lines follow. For each i (1 ≤ i ≤ N), the i-th of these lines contains three space-separated integers Wi, Hi, and Pi.
- For each test case, print a single line. If Chef cannot buy any tablet, it should contain the string "no tablet" (without quotes). Otherwise, it should contain a single integer — the maximum area of the screen of a tablet Chef can buy.
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 100
- 1 ≤ B ≤ 1,000,000
- 1 ≤ Wi, Hi ≤ 10,000
- 1 ≤ Pi ≤ 1,000,000 for each valid i
3 3 6 3 4 4 5 5 7 5 2 5 2 6 3 6 8 5 4 9 1 10 5 5 10
12 no tablet 25
- Example case 1: The first tablet (with screen area 3 * 4 = 12) is the best option for Chef, since Chef cannot afford the second one, and the third one has a smaller screen.
- Example case 2: Chef's budget is 6, but all tablets have higher prices, so Chef cannot buy any tablet.
- Example case 3: The price of the only tablet is exactly equal to Chef's budget, so he is able to buy it.
For more details, You can find the full problem description on CodeChef's website: Buying New Tablet Problem Description.
C++
Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
T = int(input())
for _ in range(T):
N, B = map(int, input().split())
max_area = -1
for _ in range(N):
W, H, P = map(int, input().split())
if P <= B:
area = W * H
if area > max_area:
max_area = area
if max_area == -1:
print("no tablet")
else:
print(max_area)
Today's Beginner problem:
- Rent a cooler at the cost of X coins per month.
- Purchase a cooler for Y coins.
- The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains two integers X and Y, as described in the problem statement.
- For each test case, output the maximum number of months for which he can rent the cooler such that the cost of renting is strictly less than the cost of purchasing it.
- If Chef should not rent a cooler at all, output 0.
- 1 ≤ T ≤ 1000
- 1 ≤ X, Y ≤ 109
2 5 12 5 5
2 0
- Test case 1: Cost of renting the cooler = 5 coins per month. Cost of purchasing the cooler = 12 coins. So, Chef can rent the cooler for 2 months at the cost of 10 coins, which is strictly less than 12 coins.
- Test case 2: Cost of renting the cooler = 5 coins per month. Cost of purchasing the cooler = 5 coins. If Chef rents the cooler for 1 month, it will cost 5 coins, which is not strictly less than the cost of purchasing it. So, Chef should not rent the cooler.
For more details, You can find the full problem description on CodeChef's website: The Cooler Dilemma 2 Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
//❌
Today's Intermediate problem:
- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains six space-separated integers A1, A2, A3, A4, A5, and P.
- 1 ≤ T ≤ 1,000
- 0 ≤ Ai ≤ 24 for each valid i
- 1 ≤ P ≤ 24
2 14 10 12 6 18 2 10 10 10 10 10 3
No Yes
- Example case 1: Here, P=2, so the number of hours Chef has to work from home to handle his workload for days 1 through 5 is [28, 20, 24, 12, 36]. If he works for full 24 hours on each of the five weekdays, he finishes all the work, so he does not have to work on weekends.
- Example case 2: No matter what Chef does, he will have to work on weekends.
For more details, You can find the full problem description on CodeChef's website: Lost Weekends Problem Description.
C++
❌ Python
❌ JavaScript
Golang
Here's an example of using the Golang
programming language:
package main
import "fmt"
func main() {
var T int
fmt.Scan(&T)
for t := 0; t < T; t++ {
var A [5]int
var P int
for i := 0; i < 5; i++ {
fmt.Scan(&A[i])
}
fmt.Scan(&P)
totalHours := 0
for i := 0; i < 5; i++ {
totalHours += A[i]
}
if totalHours * P > 120 {
fmt.Println("Yes")
} else {
fmt.Println("No")
}
}
}
Today's Beginner problem:
- The first line will contain T, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two integers X and Y, as described in the problem statement.
- For each test case, output the maximum number of chocolates Chef can buy.
- 1 ≤ T ≤ 1000
- 1 ≤ X, Y ≤ 100
4 5 10 16 5 35 7 100 1
0 3 5 100
- Test case 1: Chef has 5 rupees but the cost of one chocolate is 10 rupees. Therefore Chef cannot buy any chocolates.
- Test case 2: Chef has 16 rupees and the cost of one chocolate is 5 rupees. Therefore Chef can buy at max 3 chocolates since buying 4 chocolates would cost 20 rupees.
- Test case 3: Chef has 35 rupees and the cost of one chocolate is 7 rupees. Therefore Chef can buy at max 5 chocolates for 35 rupees.
- Test case 4: Chef has 100 rupees and the cost of one chocolate is 1 rupee. Therefore Chef can buy at max 100 chocolates for 100 rupees.
For more details, You can find the full problem description on CodeChef's website: Valentine is Coming Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the C++
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int X, Y;
cin >> X >> Y;
cout << X / Y << endl;
}
return 0;
}
Today's Intermediate problem:
- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- Each testcase contains a single line of input, five space-separated integers A, B, C, D, E.
- For each testcase, output in a single line "YES" if Chef can take all three bags with her, or "NO" if she cannot.
- You may print each character of the string in uppercase or lowercase (e.g., "yEs", "yes", "Yes," and "YES" will all be treated as identical).
- 1 ≤ T ≤ 36000
- 1 ≤ A, B, C ≤ 10
- 15 ≤ D ≤ 20
- 5 ≤ E ≤ 10
3 1 1 1 15 5 8 7 6 15 5 8 5 7 15 6
YES NO YES
- Test case 1: Chef can check-in the first and second bag (since 1 + 1 ≤ 15) and carry the third bag with her (since 1 ≤ 5).
- Test case 2: None of the three bags can be carried in hand without violating the airport restrictions.
- Test case 3: Chef can check-in the first and the third bag (since 8 + 7 ≤ 15) and carry the second bag with her (since 5 ≤ 6).
For more details, You can find the full problem description on CodeChef's website: Airline Restrictions Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the C++
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int A, B, C, D, E;
cin >> A >> B >> C >> D >> E;
if ((A + B <= D && C <= E) || (B + C <= D && A <= E) || (A + C <= D && B <= E)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
Today's Beginner problem:
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two space-separated integers N and M — the number of runs required to win the game and the remaining number of overs.
- For each test case, output on a new line, YES, if Chef's team can win the game. Otherwise, output NO.
- You can print each character in uppercase or lowercase. For example NO, no, No, and nO are all considered identical.
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1000
- 1 ≤ M ≤ 100
4 500 20 100 2 30 1 216 6
YES NO YES YES
- Test case 1: Chef's team requires 500 runs to win. If they hit 6 runs on every ball for 13 overs, they will score 6 * 6 * 13 = 468 runs. In the 14th over, they can hit 6 runs in the first five balls and 2 runs in the sixth ball to get a total of 468 + 6 * 5 + 2 = 500 runs. Thus, Chef's team can win the game.
- Test case 2: Since 100 is greater than the maximum runs that can be scored in 2 overs, it is not possible for Chef's team to win the game.
- Test case 3: Since 30 is less than the maximum runs that can be scored in 1 over, it is possible for Chef's team to win the game.
- Test case 4: Since 216 is equal to the maximum runs that can be scored in 6 overs, it is possible for Chef's team to win the game.
For more details, You can find the full problem description on CodeChef's website: Cricket Match Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the C++
programming language:
//❌
Today's Intermediate problem:
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer N —the length of Array A.
- Next line contains N space-separated integers A1, A2, A3, …, An - denoting the array A.
- For each test case, output the minimum number of operations required to make all the elements same.
- 1 ≤ T ≤ 4000
- 1 ≤ N ≤ 105
- 1 ≤ Ai ≤ N
- Sum of N over all test cases do not exceed 3 × 105
4 3 3 3 3 6 1 3 2 1 2 2 4 1 2 1 2 5 1 3 2 4 5
0 3 2 4
- Test case 1: All the elements are already the same. Thus, we need to perform zero operations.
- Test case 2: We remove the elements 1, 3, and 1 using three operations. The array becomes [2, 2, 2] where all elements are the same.
- Test case 3: We remove the elements 1 and 1 using two operations. The array becomes [2, 2] where all elements are the same.
- Test case 4: We remove the elements 1, 3, 2, and 5 using four operations. The array becomes [5].
For more details, You can find the full problem description on CodeChef's website: Remove Bad elements Problem Description.
C++
Python
❌ JavaScript
❌ Golang
Here's an example of using the C++
programming language:
//❌
Today's Beginner problem:
- The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
- Each test case consists of a single line of input, containing three space-separated integers X, Y, and Z.
- For each test case, output in a single line the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least Z seconds from now.
- 1 ≤ T ≤ 100
- 1 ≤ X, Y, Z ≤ 100
- X divides Y
3 3 3 5 2 4 1 3 12 8
4 0 4
- Test case 1: The speed of the bullet is 3 pixels per frame and the goomba is 3 pixels away from Mario. Thus, it would take 1 second for the bullet to reach the goomba. Mario wants the bullet to reach goomba after at least 5 seconds. So, he should fire the bullet after 4 seconds.
- Test case 2: The speed of the bullet is 2 pixels per frame and the goomba is 4 pixels away from Mario. Thus, it would take 2 seconds for the bullet to reach the goomba. Mario wants the bullet to reach the goomba after at least 1 second. So, he should fire the bullet after 0 seconds. Note that, this is the minimum time after which he can shoot a bullet.
- Test case 3: The speed of the bullet is 3 pixels per frame and the goomba is 12 pixels away from Mario. Thus, it would take 4 seconds for the bullet to reach the goomba. Mario wants the bullet to reach goomba after at least 8 seconds. So, he should fire the bullet after 4 seconds.
For more details, You can find the full problem description on CodeChef's website: Mario and Bullet Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the C++
programming language:
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int x, y, z, a;
cin >> x >> y >> z;
a = y / x;
if (a < z) {
cout << z - a << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
Today's Intermediate problem:
- 1 ≤ T ≤ 1000
- 1 ≤ A, B ≤ 1000
10 3 2 4 2 1 1 1 2 1 3 9 3 9 11 9 12 9 1000 8 11
Bob Limak Limak Bob Bob Limak Limak Bob Bob Bob
For more details, You can find the full problem description on CodeChef's website: Bear and Candies 123 Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the C++
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int A, B;
cin >> A >> B;
int moves = 1;
while (true) {
if (moves % 2 == 1) {
A -= moves;
if (A < 0) {
cout << "Bob" << endl;
break;
}
} else {
B -= moves;
if (B < 0) {
cout << "Limak" << endl;
break;
}
}
moves++;
}
}
return 0;
}
Today's Beginner problem:
-
Problem: Chef is currently working for a secret research group called NEXTGEN. While the rest of the world is still in search of a way to utilize Helium-3 as a fuel, NEXTGEN scientists have been able to achieve 2 major milestones:
- Finding a way to make a nuclear reactor that will be able to utilize Helium-3 as a fuel
- Obtaining every bit of Helium-3 from the moon's surface
- Input Format: The first line of input contains an integer T, the number of testcases. The description of T test cases follows. Each test case consists of a single line of input, containing four space-separated integers A, B, X, Y respectively.
- Output Format: For each test case print on a single line the answer — Yes if NEXTGEN satisfies the government's minimum requirements for funding and No otherwise. You may print each character of the answer string in either uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).
-
Constraints:
- 1 ≤ T ≤ 1000
- 1 ≤ A, B, X, Y ≤ 1000
For more details, You can find the full problem description on CodeChef's website: Chef and NextGen Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the Python
programming language:
t = int(input())
for _ in range(t):
a, b, x, y = map(int, input().split())
if a * b <= x * y:
print("Yes")
else:
print("No")
Today's Intermediate problem:
- Problem: Chef is working on a project for NEXTGEN. They need to power Chefland by generating at least A units of power each year for the next B years using Helium-3 from the moon.
- Input Format: The first line contains an integer T, the number of test cases. Each test case contains four space-separated integers A, B, X, and Y.
- Output Format: For each test case, print "Yes" if the project can generate enough power, or "No" otherwise.
-
Constraints:
- 1 ≤ T ≤ 1000
- 1 ≤ A, B, X, Y ≤ 1000
For more details, You can find the full problem description on CodeChef's website: Odd Pairs Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Beginner problem:
- Problem: Chef is currently standing at stair 0 and he wants to reach stair numbered X.
- Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of a single line of input containing two space-separated integers X and Y denoting the number of stairs Chef wants to reach and the number of stairs he can climb in one move.
- Output Format: For each test case, output the minimum number of moves required by him to reach exactly the stair numbered X.
-
Constraints:
- 1 ≤ T ≤ 500
- 1 ≤ X, Y ≤ 100
For more details, You can find the full problem description on CodeChef's website: X Jumps Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the C++
programming language:
// Your_code_here
Today's Intermediate problem:
-
Problem: There are three friends; let's call them A, B, C. They made the following statements:
- A: "I have x Rupees more than B."
- B: "I have y rupees more than C."
- C: "I have z rupees more than A."
- Input Format: The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first and only line of each test case contains three space-separated integers X, Y, and Z.
- Output Format: For each test case, print a single line containing the string "yes" if the presented scenario is possible or "no" otherwise (without quotes).
-
Constraints:
- 1 ≤ T ≤ 1,000
- 1 ≤ X, Y, Z ≤ 1,000
-
Sample:
Input 2 1 2 1 1 1 1 Output yes no
Explanation:
Example 1: One possible way to satisfy all conditions is: A has 10 rupees, B has 9 rupees, and C has 11 rupees. Therefore, we have x=1, y=-2, z=1.
Example 2: There is no way for all conditions to be satisfied.
For more details, You can find the full problem description on CodeChef's website: Three Friends Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the Python
programming language:
package main
import (
"fmt"
)
func main() {
var T int
fmt.Scan(&T)
for i := 0; i < T; i++ {
var X, Y, Z int
fmt.Scan(&X, &Y, &Z)
if X == Y+Z || Y == Z+X || Z == X+Y {
fmt.Println("yes")
} else {
fmt.Println("no")
}
}
}
Today's Beginner problem:
- Problem: There are N cards on a table, out of which X cards are face-up and the remaining are face-down. In one operation, we can do the following: Select any one card and flip it (i.e., if it was initially face-up, after the operation, it will be face-down and vice versa). What is the minimum number of operations we must perform so that all the cards face in the same direction (i.e., either all are face-up or all are face-down)?
- Input Format: The first line contains a single integer T — the number of test cases. Then the test cases follow. The first and only line of each test case contains two space-separated integers N and X — the total number of cards and the number of cards which are initially face-up.
- Output Format: For each test case, output the minimum number of cards you must flip so that all the cards face in the same direction.
-
Constraints:
- 1 ≤ T ≤ 5000
- 2 ≤ N ≤ 100
- 0 ≤ X ≤ N
-
Sample:
Input 4 5 0 4 2 3 3 10 2
Output 0 2 0 2 </pre> <p>Explanation:</p> <p>Test Case 1: All the cards are already facing down. Therefore we do not need to perform any operations.</p> <p>Test Case 2: 2 cards are facing up and 2 cards are facing down. Therefore we can flip the 2 cards which are initially facing down.</p> <p>Test Case 3: All the cards are already facing up. Therefore we do not need to perform any operations.</p> <p>Test Case 4: 2 cards are facing up and 8 cards are facing down. Therefore we can flip the 2 cards which are initially facing up.</p>
For more details, You can find the full problem description on CodeChef's website: Flip the cards Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N, X;
cin >> N >> X;
int flips = min(X, N - X);
cout << flips << endl;
}
return 0;
}
Today's Intermediate problem:
- Problem: Well-known investigative reporter Kim "Sherlock" Bumjun needs your help! Today, his mission is to sabotage the operations of the evil JSA. If the JSA is allowed to succeed, they will use the combined power of the WQS binary search and the UFDS to take over the world! But Kim doesn't know where the base is located. He knows that the base is on the highest peak of the Himalayan Mountains. He also knows the heights of each of the N mountains. Can you help Kim find the height of the mountain where the base is located?
- Input Format: First line will contain T, the number of test cases. Then the test cases follow. The first line in each testcase contains one integer, N. The following N lines of each test case each contain one integer: the height of a new mountain.
- Output Format: For each testcase, output one line with one integer: the height of the tallest mountain for that test case.
-
Constraints:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 100000
- 0 ≤ height of each mountain ≤ 10^9
-
Subtasks:
- 100 points: No additional constraints.
-
Sample 1:
Input 1 5 4 7 6 3 1 7
Output
7
For more details, You can find the full problem description on CodeChef's website: Peak Finding Problem Description.
C++
❌ Python
❌ JavaScript
Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
int tallest = -1;
for (int i = 0; i < N; i++) {
int height;
cin >> height;
tallest = max(tallest, height);
}
cout << tallest << endl;
}
return 0;
}
Today's Beginner problem:
- Problem: Chef has N candies. He has to distribute them to exactly M of his friends such that each friend gets an equal number of candies, and each friend gets an even number of candies. Determine whether it is possible to do so.
- Input Format: First line will contain T, the number of test cases. Then the test cases follow. Each test case consists of a single line of input, two integers N and M, the number of candies and the number of friends.
- Output Format: For each test case, the output will consist of a single line containing "Yes" if Chef can distribute the candies as per the conditions and "No" otherwise. You may print each character of the string in uppercase or lowercase (for example, the strings "yes," "Yes," "yEs," and "YES" will all be treated as identical).
-
Constraints:
- 1 ≤ T ≤ 1000
- 1 ≤ N, M ≤ 1000
-
Sample 1:
Input 4 9 3 4 1 4 2 8 3
Output
No Yes Yes No
For more details, You can find the full problem description on CodeChef's website: Candy Distribution Problem Description.
C++
Python
❌ JavaScript
Golang
Here's an example of using the Golang
programming language:
package main
import (
"fmt"
)
func main() {
var T int
fmt.Scan(&T)
for i := 0; i < T; i++ {
var N, M int
fmt.Scan(&N, &M)
if N%(2*M) == 0 {
fmt.Println("Yes")
} else {
fmt.Println("No")
}
}
}
Today's Intermediate problem:
-
Problem: Chef has a total of N (N≥4) chocolates. He decided to distribute them into three jars such that:
- At least one jar has an odd number of chocolates.
- Exactly two jars have the same number of chocolates.
- Every jar has at least one chocolate.
- Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of a single integer N — the total number of chocolates.
- Output Format: For each test case, output on a new line, three space-separated integers denoting the number of chocolates in each jar after distribution.
-
Constraints:
- 1 ≤ T ≤ 10^5
- 4 ≤ N ≤ 10^5
-
Sample 1:
Input 3 4 7 11
Output
1 1 2 1 3 3 1 5 5
For more details, You can find the full problem description on CodeChef's website: Chocolate Distribution Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
// Your_code_here
Today's Beginner problem:
-
Problem: There is a bus with 30 seats. The seats are numbered from 1 to 30, and the numbering is as depicted in this image.
[Image depicting bus seat layout]
As can be seen in the image, the bus is divided into two decks - The Lower deck, and the Upper deck, with 15 seats each. And some of the seats come as Single and some as Double. For example, Seats 1 and 2 are Double, whereas Seat 11 is a Single. You will be given a Seat number, and your job is to classify it as one of these 4 types:- Lower Single
- Lower Double
- Upper Single
- Upper Double
- Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of a single integer N — the seat number.
- Output Format: For each test case, output on a new line, the type of seat.
-
Constraints:
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 30
-
Sample 1:
Input 5 6 28 16 13 10
Output
Lower Double Upper Single Upper Double Lower Single Lower Double
For more details, You can find the full problem description on CodeChef's website: Bus Seat Numbering Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Intermediate problem:
- Problem: CodeChef offers a feature called streak count. A streak is maintained if you solve at least one problem daily. Om and Addy actively maintain their streaks on CodeChef. Over a span of N consecutive days, you have observed the count of problems solved by each of them. Your task is to determine the maximum streak achieved by Om and Addy and find who had the longer maximum streak.
- Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of multiple lines of input. The first line of each test case contains an integer N — the number of days. The second line of each test case contains N space-separated integers, the ith of which is Ai, representing the problems solved by Om on the ith day. The third line of each test case contains N space-separated integers, the ith of which is Bi, representing the problems solved by Addy on the ith day.
-
Output Format: For each test case, output:
- OM, if Om has a longer maximum streak than Addy;
- ADDY, if Addy has a longer maximum streak than Om;
- DRAW, if both have equal maximum streak.
-
Constraints:
- 1 ≤ T ≤ 10^5
- 1 ≤ N ≤ 10^5
- 0 ≤ Ai, Bi ≤ 10^9
- The sum of N over all test cases won't exceed 6 * 10^5.
-
Sample 1:
Input 3 6 1 7 3 0 2 13 0 2 3 4 5 0 3 1 3 4 3 1 2 5 1 2 3 0 1 1 2 0 2 3
Output
Addy Draw Om
For more details, You can find the full problem description on CodeChef's website: CodeChef Streak Problem Description.
❌ C++
Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
def find_max_streak(N, om_solved, addy_solved):
om_streak = 0
addy_streak = 0
max_om_streak = 0
max_addy_streak = 0
for i in range(N):
if om_solved[i] > 0:
om_streak += 1
else:
om_streak = 0
if addy_solved[i] > 0:
addy_streak += 1
else:
addy_streak = 0
max_om_streak = max(max_om_streak, om_streak)
max_addy_streak = max(max_addy_streak, addy_streak)
if max_om_streak > max_addy_streak:
return "OM"
elif max_addy_streak > max_om_streak:
return "ADDY"
else:
return "DRAW"
T = int(input())
for _ in range(T):
N = int(input())
om_solved = list(map(int, input().split()))
addy_solved = list(map(int, input().split()))
result = find_max_streak(N, om_solved, addy_solved)
print(result)
Today's Beginner problem:
- Problem: Alice is playing Air Hockey with Bob. The first person to earn seven points wins the match. Currently, Alice's score is **A** and Bob's score is **B**. Charlie is eagerly waiting for his turn. Help Charlie by calculating the minimum number of points that will be further scored in the match before it ends.
-
Input Format:
- The first line of input will contain an integer **T** — the number of test cases. The description of **T** test cases follows.
- The first and only line of each test case contains two space-separated integers **A** and **B**, as described in the problem statement.
-
Output Format:
- For each test case, output on a new line the minimum number of points that will be further scored in the match before it ends.
-
Constraints:
- 1 ≤ **T** ≤ 50
- 0 ≤ **A**, **B** ≤ 6
-
Sample Input and Output:
Input 4 0 0 2 5 5 2 4 3
Output 7 2 2 3 </pre>
For more details, You can find the full problem description on CodeChef's website: Air Hockey Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int A, B;
cin >> A >> B;
cout << 7 - max(A, B) << endl;
}
return 0;
}
Today's Intermediate problem:
- Problem: For a positive integer N, find the smallest integer X strictly greater than N such that digitSum(N) and digitSum(X) have different parity, i.e., one of them is odd, and the other is even.
- Input Format: The first line contains an integer T, the number of test cases. The description of the T test cases follows. Each test case consists of a single line of input with a single integer, the number N.
- Output Format: For each test case, print in a single line, an integer, the answer to the problem.
-
Constraints:
- 1 ≤ T ≤ 1000
- 1 ≤ N < 10^9
-
Sample 1:
Input 3 123 19 509
Output
124 21 511
For more details, You can find the full problem description on CodeChef's website: Digit Sum Parities Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Beginner problem:
- Problem
- There is a contest containing
- 2 problems A and B.
- 2 strong participants P and Q participated in the contest and solved both the problems.
- P made AC submissions on problems A and B at time instants P_A and P_B respectively while Q made AC submissions on problems A and B at time instants Q_A and Q_B.
- It is given that the time penalty is the minimum time instant at which a participant has solved both the problems. Also, the participant with the lower time penalty will have a better rank.
- Determine which participant got the better rank or if there is a TIE.
- Input Format
- The first line will contain T, number of test cases. Then the test cases follow.
- Each test case contains a single line of input, four integers P_A, P_B, Q_A, Q_B.
- Output Format
- For each test case, output P if P got a better rank, Q if Q got a better rank, TIE otherwise.
- Note that output is case-insensitive i.e. P and p both are considered the same.
- Constraints
- 1 ≤ T ≤ 1000
- 1 ≤ P_A, P_B, Q_A, Q_B ≤ 100
- Sample 1:
- Input
- Output
- 4
- 5 10 2 12
- 10 30 15 15
- 20 8 4 20
- 6 6 6 6
- P
- Q
- TIE
- TIE
- Explanation:
- Test Case 1:
- Time penalty incurred by participant P = 10.
- Time penalty incurred by participant Q = 12.
- Since 10 < 12, P gets a better rank.
- Test Case 2:
- Time penalty incurred by participant P = 30.
- Time penalty incurred by participant Q = 15.
- Since 15 < 30, Q gets a better rank.
- Test Case 3:
- Time penalty incurred by participant P = 20.
- Time penalty incurred by participant Q = 20.
- Since 20 = 20, P and Q get the same rank (TIE).
- Test Case 4:
- Time penalty incurred by participant P = 6.
- Time penalty incurred by participant Q = 6.
- Since 6 = 6, P and Q get the same rank (TIE).
For more details, You can find the full problem description on CodeChef's website: Determine the Winner Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the C++
programming language:
#include <iostream>
#include <string>
using namespace std;
int digitSum(int n) {
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
int X = N + 1;
while (true) {
int sum_N = digitSum(N);
int sum_X = digitSum(X);
if (sum_N % 2 != sum_X % 2) {
cout << X << endl;
break;
}
X++;
}
}
return 0;
}
Today's Intermediate problem:
- Problem
- Ram wants to generate some prime numbers for his cryptosystem. Help him please! Your task is to generate all prime numbers between two given numbers.
- Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)
- Input Format
- The first line contains t, the number of test cases (less than or equal to 10).
- Followed by t lines which contain two numbers m and n (1 ≤ m ≤ n ≤ 1,000,000,000, n-m≤100,000) separated by a space.
- Output Format
- For every test case, print all prime numbers p such that m ≤ p ≤ n, one number per line. Separate the answers for each test case by an empty line.
- Constraints
- (1 ≤ m ≤ n ≤ 1,000,000,000, n-m≤100,000)
- Sample 1:
- Input
- Output
- 2
- 1 10
- 3 5
- 2
- 3
- 5
- 7
- 3
- 5
For more details, You can find the full problem description on CodeChef's website: Prime Generator Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Beginner problem:
- Problem
- Chef is watching TV. The current volume of the TV is X. Pressing the volume up button of the TV remote increases the volume by 1 while pressing the volume down button decreases the volume by 1. Chef wants to change the volume from X to Y. Find the minimum number of button presses required to do so.
- Input Format
- The first line contains a single integer T - the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two integers X and Y - the initial volume and final volume of the TV.
- Output Format
- For each test case, output the minimum number of times Chef has to press a button to change the volume from X to Y.
- Constraints
- 1 ≤ T ≤ 100
- 1 ≤ X, Y ≤ 100
- Sample 1:
- Input
- Output
- 2
- 50 54
- 12 10
- 4
- 2
- Explanation:
- Test Case 1: Chef can press the volume up button 4 times to increase the volume from 50 to 54.
- Test Case 2: Chef can press the volume down button 2 times to decrease the volume from 12 to 10.
For more details, You can find the full problem description on CodeChef's website: Volume Control Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int X, Y;
cin >> X >> Y;
int diff = abs(X - Y);
cout << diff << endl;
}
return 0;
}
Today's Intermediate problem:
- Problem
- N candidates (numbered from 1 to N) join Chef's firm. The first 5 candidates join on the first day, and then, on every subsequent day, the next 5 candidates join in.
- For example, if there are 12 candidates, candidates numbered 1 to 5 will join on day 1, candidates numbered 6 to 10 on day 2, and the remaining 2 candidates will join on day 3.
- Candidate numbered K decided to turn down his offer and thus, Chef adjusts the position by shifting up all the higher numbered candidates. This leads to a change in the joining day of some of the candidates.
- Input Format
- First line will contain T, number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, two space-separated integers N and K denoting the number of candidates and the candidate who turned down the offer.
- Output Format
- For each test case, output a single integer denoting the number of candidates whose joining day will be changed.
- Constraints
- 1 ≤ T ≤ 1000
- 2 ≤ N ≤ 1000
- 1 ≤ K ≤ N
- Sample 1:
- Input
- Output
- 4
- 7 3
- 6 6
- 2 1
- 14 2
- 1
- 0
- 0
- 2
- Explanation:
- Test case 1: The original joining day of each candidate is given as [1, 1, 1, 1, 1, 2, 2] but as candidate 3 turns down his offer, the new joining days are now [1, 1, NA, 1, 1, 1, 2]. Candidate numbered 6 is the only one to have his joining day changed.
- Test case 2: The original joining day of each candidate is given as [1, 1, 1, 1, 1, 2] but as candidate 6 turns down his offer, the new joining days are now [1, 1, 1, 1, 1, NA]. No candidate got his joining day changed.
- Test case 3: The original joining day of each candidate is given as [1, 1] but as candidate 1 turns down his offer, the new joining days are now [NA, 1]. No candidate got his joining day changed.
- Test case 4: The original joining day of each candidate is given as [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3] but as candidate 2 turns down his offer, the new joining days are now [1, NA, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3]. Candidate numbered 6 and 11 are the only ones to have their joining days changed.
For more details, You can find the full problem description on CodeChef's website: Joining Date Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Beginner problem:
- Problem
- Bob has an account in the Bobby Bank. His current account balance is W rupees.
- Each month, the office in which Bob works deposits a fixed amount of X rupees to his account.
- Y rupees is deducted from Bob's account each month as bank charges.
- Find his final account balance after Z months. Note that the account balance can be negative as well.
- Input Format
- The first line will contain T, the number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, containing four integers W, X, Y, and Z — the initial amount, the amount deposited per month, the amount deducted per month, and the number of months.
- Output Format
- For each test case, output in a single line the final balance in Bob's account after Z months.
- Constraints
- 1 ≤ T ≤ 1000
- 1 ≤ W, X, Y, Z ≤ 10^4
- Sample 1:
- Input
- Output
- 3
- 100 11 1 10
- 999 25 36 9
- 2500 100 125 101
- 200
- 900
- -25
- Explanation:
- Test case 1: Bob's current account balance is 100. At the end of each month, Bob gets Rs 11 and pays Rs 1, thus gaining 10 per month. Thus, at the end of 10 months, Bob will have 100 + 10 × 10 = 200.
- Test case 2: Bob's current account balance is 999. At the end of each month, Bob gets Rs 25 and pays Rs 36, thus losing 11 per month. Thus, at the end of 9 months, Bob will have 999 − 11 × 9 = 900.
- Test case 3: Bob's current account balance is 2500. At the end of each month, Bob gets Rs 100 and pays Rs 125, thus losing 25 per month. Thus, at the end of 101 months, Bob will have 2500 − 25 × 101 = -25.
For more details, You can find the full problem description on CodeChef's website: Bob at the Bank Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int w, x, y, z;
cin >> w >> x >> y >> z;
int final_balance = w + (x - y) * z;
cout << final_balance << endl;
}
return 0;
}
Today's Intermediate problem:
- Problem
- Janmansh is at the fruit market to buy fruits for Chingari. There is an infinite supply of three different kinds of fruits with prices A, B, and C.
- He needs to buy a total of X fruits having at least 2 different kinds of fruits. What is the least amount of money he can spend to buy fruits?
- Input Format
- The first line of the input contains a single integer T - the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains four space-separated integers X, A, B, C - the number of fruits to buy and the prices of the three different types of fruits, respectively.
- Output Format
- For each test case, output the least amount of money he can spend to buy fruits.
- Constraints
- 1 ≤ T ≤ 10^5
- 2 ≤ X ≤ 1000
- 1 ≤ A, B, C ≤ 100
- Sample 1:
- Input
- Output
- 2
- 2 1 1 1
- 3 4 3 2
- 2
- 7
- Explanation:
- Test case-1: He can buy any two fruits of different kinds for a total price of 2.
- Test case-2: He can buy 1 fruit of price 3 and 2 fruits of price 2 for a total price of 7.
For more details, You can find the full problem description on CodeChef's website: Janmansh at Fruit Market Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Beginner problem:
- Problem
- There are 100 questions in a paper. Each question carries +3 marks for a correct answer, -1 marks for an incorrect answer, and 0 marks for an unattempted question.
- It is given that Chef received exactly X (0 ≤ X ≤ 100) marks. Determine the minimum number of problems Chef marked incorrect.
- Input Format
- First line will contain T, the number of test cases. Then the test cases follow.
- Each test case consists of a single integer X, marks that Chef received.
- Output Format
- For each test case, output the minimum number of problems Chef marked incorrect.
- Constraints
- 1 ≤ T ≤ 100
- 0 ≤ X ≤ 100
- Sample 1:
- Input
- Output
- 4
- 0
- 100
- 32
- 18
- 0
- 2
- 1
- 0
- Explanation:
- Test Case 1: It might be possible that Chef didn't attempt any question, in which case he didn't get any question incorrect.
- Test Case 2: For the case when Chef got 34 questions correct and 2 questions incorrect, Chef marked the minimum number of incorrect questions.
- Test Case 3: For the case when Chef got 11 questions correct and 1 question incorrect, Chef marked the minimum number of incorrect questions.
- Test Case 4: For the case when Chef got 6 questions correct and no question incorrect, Chef marked the minimum number of incorrect questions.
For more details, You can find the full problem description on CodeChef's website: High Accuracy Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int X;
cin >> X;
int incorrect = 0;
if (X % 3 == 0) {
incorrect = 0;
} else if (X % 3 == 1) {
incorrect = 2;
} else {
incorrect = 1;
}
cout << incorrect << endl;
}
return 0;
}
Today's Intermediate problem:
- Problem
- Write a program to obtain 2 numbers (A and B) and an arithmetic operator (C) and then design a calculator depending upon the operator entered by the user.
- For example, if C = "+", you have to sum the two numbers.
- If C = "-", you have to subtract the two numbers.
- If C = "*", you have to print the product.
- If C = "/", you have to divide the two numbers.
- Input Format
- First line will contain the first number A.
- Second line will contain the second number B.
- Third line will contain the operator C, that is to be performed on A and B.
- Output Format
- Output a single line containing the answer obtained by performing the operator on the numbers.
- Your output will be considered correct if the difference between your output and the actual answer is not more than 10^-6.
- Constraints
- -1000 ≤ A ≤ 1000
- -1000 ≤ B ≤ 1000
- B ≠ 0
- C can only be one of these 4 operators: {"+", "-", "*", "/"}
- Sample 1:
- Input
- Output
- 8
- 2
- /
- 4.0
- Sample 2:
- Input
- Output
- 5
- 3
- +
- 8
For more details, You can find the full problem description on CodeChef's website: Program Your Own CALCULATOR Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
double A, B, result;
char opr;
cin >> A;
cin >> B;
cin >> opr;
switch (opr) {
case '+':
result = A + B;
break;
case '-':
result = A - B;
break;
case '*':
result = A * B;
break;
case '/':
if (B == 0) {
cout << "Undefined" << endl;
return 0;
}
result = A / B;
break;
default:
cout << "Invalid operator" << endl;
return 0;
}
cout << fixed << result << endl;
return 0;
}
Today's Beginner problem:
- Problem: Alice, Bob, and Charlie want to buy a Netflix subscription. However, Netflix allows only two users to share a subscription. Given that Alice, Bob, and Charlie have specific amounts of money and the cost of a Netflix subscription, determine if any two of them can contribute to buy a subscription.
- Input Format: The first line of input contains an integer T, the number of test cases. Each test case consists of four space-separated integers: A, B, C, and X — the amounts Alice, Bob, and Charlie have, and the cost of a Netflix subscription, respectively.
- Output Format: For each test case, output "YES" if any two of them can contribute to buy a Netflix subscription, or "NO" otherwise. You may print the result in either uppercase or lowercase.
-
Constraints:
- 1 ≤ T ≤ 1000
- 1 ≤ A, B, C, X ≤ 100
-
Sample 1:
Input 4 1 1 1 3 2 3 1 5 4 2 3 4 2 1 4 7
Output
NO YES YES NO
For more details, You can find the full problem description on CodeChef's website: Netflix Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the Cpp
programming language:
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int A, B, C, X;
cin >> A >> B >> C >> X;
if ((A + B >= X) || (A + C >= X) || (B + C >= X)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
Today's Intermediate problem:
- Problem: Chef wants to estimate the skill level of participants in a coding competition. Each participant can be classified based on the number of problems they solved as follows:
- 0 problems: Beginner
- 1 problem: Junior Developer
- 2 problems: Middle Developer
- 3 problems: Senior Developer
- 4 problems: Hacker
- 5 problems: Jeff Dean
- Input:
- The first line of the input contains a single integer N denoting the number of competitors.
- N lines follow. The i-th of these lines contains five space-separated integers Ai, 1, Ai, 2, Ai, 3, Ai, 4, Ai, 5. The j-th of these integers (1 ≤ j ≤ 5) is 1 if the i-th contestant solved the j-th problem and 0 otherwise.
- Output: For each participant, print a single line containing one string denoting Chef's classification of that contestant — one of the strings "Beginner," "Junior Developer," "Middle Developer," "Senior Developer," "Hacker," "Jeff Dean" (without quotes).
- Constraints:
- 1 ≤ N ≤ 5000
- 0 ≤ Ai, j ≤ 1 for each valid i, j
- Sample 1:
Input 7 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1 1 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 0
Output
Beginner Middle Developer Junior Developer Jeff Dean Senior Developer Hacker Hacker
For more details, You can find the full problem description on CodeChef's website: Chef and Cook-Off Problem Description.
❌ C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Python
programming language:
// Your_code_here
Today's Beginner problem:
- Problem: Chef wants to gift C chocolates to Botswal on his birthday. However, he has only X chocolates with him. The cost of 1 chocolate is Y rupees. Find the minimum money in rupees Chef needs to spend so that he can gift C chocolates to Botswal.
- Input Format: The first line will contain T, the number of test cases. Then the test cases follow. Each test case consists of a single line of input, three integers: C, X, and Y.
- Output Format: For each test case, output in a single line the answer, the minimum money in rupees Chef needs to spend.
-
Constraints:
- 1 ≤ T ≤ 100
- 1 ≤ C ≤ 100
- 0 ≤ X ≤ C
- 1 ≤ Y ≤ 100
-
Sample 1:
Input 2 7 5 5 10 1 1
Output
10 9
For more details, You can find the full problem description on CodeChef's website: Chef and Chocolates Problem Description.
C++
❌ Python
❌ JavaScript
❌ Golang
Here's an example of using the Cpp
programming language:
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int C, X, Y;
cin >> C >> X >> Y;
int money_spent = 0;
if (X >= C) {
money_spent = 0;
} else {
int chocolates_needed = C - X;
money_spent = chocolates_needed * Y;
}
cout << money_spent << endl;
}
return 0;
}
Today's Intermediate problem:
- Problem: Chef has a number X whose value is initially 0. In one move, he can either increment X by 2 (X := X + 2) or decrement X by 1 (X := X - 1). Chef can perform at most Y moves. Find the number of distinct values X can have after performing at most Y moves.
- Input Format: The first line of input contains a single integer T, denoting the number of test cases. The first and only line of each test case contains an integer Y, the maximum number of moves Chef can perform.
- Output Format: For each test case, output the number of distinct values X can have after performing at most Y moves.
-
Constraints:
- 1 ≤ T ≤ 1000
- 0 ≤ Y ≤ 10^6
-
Sample 1:
Input 3 0 1 2
Output
1 3 6
For more details, You can find the full problem description on CodeChef's website: Plus 2 or Minus 1 Problem Description.
C++
Python
JavaScript
Golang
Here's an example of using the Python
programming language:
// Your_code_here
Ashish Singh |