0% found this document useful (0 votes)
20 views7 pages

Competitive Coding

The document presents a series of competitive coding problems focused on problem-solving using C language. It includes scenarios such as determining if a character will drink mango lassi based on temperature, checking if a student can complete an assignment in time, and evaluating the outcomes of a cricket match. Additional problems involve choosing the cheaper cab service, counting holidays in a month, and calculating ATM withdrawal balances with specific conditions.

Uploaded by

romy sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

Competitive Coding

The document presents a series of competitive coding problems focused on problem-solving using C language. It includes scenarios such as determining if a character will drink mango lassi based on temperature, checking if a student can complete an assignment in time, and evaluating the outcomes of a cricket match. Additional problems involve choosing the cheaper cab service, counting holidays in a month, and calculating ATM withdrawal balances with specific conditions.

Uploaded by

romy sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Competitive Coding………..

Lets join the Coding Fun

Problem Solving Using C Language

#1 Summer Time
Mamalesh likes to drink mango lassi when it's hot, and only when it's hot. If (and only if) the
temperature on a given day is strictly greater than 35 degrees, Mamalesh will drink mango
lassi. Mamalesh sees that today's temperature is XX degrees Celsius. Will he drink mango lassi
today?Print "Yes" if he will, and "No" otherwise (without quotes).

Input Format

 The only line of input will contain a single integer XX, denoting today's temperature.

Output Format

Print "YES" if Mamalesh will drink mango lassi today, and "NO" otherwise (without quotes).
Each letter of the output may be printed in either uppercase or lowercase, i.e, the
strings NO, no, No, and nO will all be treated as equivalent.
Competitive Coding………..Lets join the Coding Fun

Problem Solving Using C Language

#2. Writing Speed

Rahul has a 55-page assignment due in 6060 minutes. He can write one page in XX minutes.

Determine if Rahul can complete the assignment within the given time constraint.

Input Format

 The only line of input will contain a single integer XX, denoting the time taken (in minutes) by
Rahul to write one page.

Output Format

Print YES if Rahul can complete the assignment in time, otherwise print NO.
You may print each character of the output in either uppercase or lowercase (for example, the
strings YES, yEs, yes, and yeS will all be treated as identical).
Competitive Coding………..Lets join the Coding Fun
Problem Solving Using C Language
#3 RCB vs CSK
In the recent RCB vs CSK match, RCB batted first and scored XX runs while CSK batted second and
scored YY runs.
It is known that RCB qualifies to the playoffs if they win by at least 1818 runs, otherwise CSK qualify.
Knowing the final scores of both teams, find out who qualified to the playoffs.

Input Format
 The only line of input contains 22 integers XX and YY - the final scores of RCB and
CSK respectively.

Output Format
Output RCB if RCB managed to qualify to the playoffs, otherwise output CSK.
You may print each character of the string in uppercase or lowercase (for example, the
strings RCB, rCb, rcb, and rcB will all be treated as identical).

Sample 1:
Input 218 191

Output RCB

Explanation:
RCB won by 218−191=27218−191=27 runs, which is more than 1818. Thus, RCB
qualified.

Sample 2:
Input 218 201

Output CSK
Explanation:
RCB won by 218−201=17218−201=17 runs, which is less than 1818. Thus, CSK qualified.

Competitive Coding………..Lets join the Coding Fun


Problem Solving Using C Language
#4. The Cheaper Cab
Chef has to travel to another place. For this, he can avail any one of two cab services.
 The first cab service charges XX rupees.
 The second cab service charges YY rupees.
Chef wants to spend the minimum amount of money. Which cab service should Chef take?

Input Format

 The first line will contain TT - the number of test cases. Then the test cases follow.
 The first and only line of each test case contains two integers XX and YY - the prices of first
and second cab services respectively.

Output Format

For each test case, output FIRST if the first cab service is cheaper, output SECOND if the second
cab service is cheaper, output ANY if both cab services have the same price.
You may print each character of FIRST, SECOND and ANY in uppercase or lowercase (for
example, any, aNy, Any will be considered identical).

Sample 1:
Input output

30 65 FIRST
90 50 Second
42 42 ANY
Competitive Coding………..Lets join the Coding Fun
Problem Solving Using C Language

#5. Count the Holidays


A particular month has 3030 days, numbered from 11 to 3030.
Day 11 is a Monday, and the usual 77-day week is followed (so day 22 is Tuesday, day 33 is
Wednesday, and so on).
Every Saturday and Sunday is a holiday. There are NN festival days, which are also holidays.
Note that it is possible for a festival day to occur on a Saturday or Sunday.

You are given the dates of the festivals. Determine the total number of holidays in this month.

Input Format
 The first line of input contains a single integer TT, denoting the number of test cases.
The description of TT test cases follows.
 The first line of each test case contains an integer NN denoting the number of festival
days.
 The second line of each test case contains NN distinct space-separated
integers A1,A2,…ANA1,A2,…AN, denoting the festival days. Note that
the AiAi are not necessarily given in sorted order.

Output Format
For each test case, output a new line containing the total number of holidays.

Explanation:
Test Case 11: Days 6,13,206,13,20 and 2727 are Saturdays, and
days 7,14,21,287,14,21,28 are Sundays. The festivals fall on day 55 and day 77,
but day 77 is already a Sunday. This gives us 99 holidays in total —
days 5,6,7,13,14,20,21,27,285,6,7,13,14,20,21,27,28.
Test Case 22: Days 6,13,206,13,20 and 2727 are Saturdays, and
days 7,14,21,287,14,21,28 are Sundays. The festivals fall on day 11, day 66, and
day 2323. This gives us 1010 holidays in total —
days 1,6,7,13,14,20,21,23,27,281,6,7,13,14,20,21,23,27,28.

Competitive Coding………..Lets join the Coding Fun


Problem Solving Using C Language

#6.ATM
Pooja would like to withdraw X US Dollar from an ATM. The cash machine will only accept the
transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the
withdrawal transaction (including bank charges). For each successful withdrawal the bank
charges 0.50 US Dollar.

Calculate Pooja's account balance after an attempted transaction.

Input Format

Each input contains 2 numbers XX and YY.


XX is the amount of cash which Pooja wishes to withdraw.
YY is Pooja's initial account balance.

Output Format

Output the account balance after the attempted transaction, given as a number with two digits of
precision. If there is not enough money in the account to complete the transaction, output the
current bank balance.
.Sample 1:
Input
Output
30 120.00
89.50
Explanation:

Example - Successful Transaction


Sample 2:
Input
Output
42 120.00
120.00
Explanation:Example - Incorrect Withdrawal Amount (not multiple of 5)

You might also like