Course outline
Pre-Requisite Assignment
Week 1: Introduction
Week 2: Introduction to Python
Week 3: Cool Ideas (Part 1)
Week 4: Cool Ideas (Part 2)
Week 5
Week 6: Cool Ideas (Part 4)
Week 7: Cool Ideas(Part 5)
Week 8: Cool Ideas(Part 6)
Week 9: Cool Ideas(Part 7)
Week 10: Cool Ideas(Part 8)
Week 11
Week 12
DOWNLOAD VIDEOS
TEXT TRANSCRIPTION
3rd Nov Programming Test Session-1 (10am-11am)
SET-1: Choosing Balls
In Progress
SET-1: Choosing Balls
Due on 2019-11-03, 11:00 IST
There are N balls in a row numbered 1 to N from left to right. For each ball i, Bi represents its size. You are initially on the leftmost ball (ball number 1). You can make an arbitrary number of choices (including zero) as long as the following conditions are satisfied:
You can only choose a ball which is next to the current ball i.e. from ith ball, you can choose i+1th ball i.e. next right (if exists).
It’s always possible to choose a ball with the same size as the current ball.
It’s possible to choose a ball if its size is larger than the current ball by no more than U.
It’s possible to choose a ball if its size is smaller than the current ball by no more than D.
You have one special choice where you can choose a smaller ball regardless of its size (as long as it is smaller than the current ball). This choice is available at most one time.
Your task is to choose the highest indexed ball. Determine the index of the rightmost ball you can reach.
Input Format:
The first line of the input contains three space-separated integers N, U, and D
The second line contains N space-separated integers B1, B2, …, BN.
Output Format:
Print a single line containing one integer -- the index of the rightmost reachable ball.
Constraints:
1<= N <=100
1<=U, D<=1,00,000
1<= Bi <=1,00,000
Example:
Input:
5 3 2
2 5 2 6 3
Output:
3
Answers
Answered by
0
Answer:
Please send a pic soo I can able to answer
Similar questions