Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Profit Development: Tyler Durden is a salesperson and is assigned a task to travel to sell soaps. He must travel to different countries with S

Profit Development:
Tyler Durden is a salesperson and is assigned a task to travel to sell soaps.
He must travel to different countries with S states each.
His manager has also provided him with an integer array A, of length N.
Array 'A' represents a rating list that shows the past sales in a certain state.
Below are a few rules for him to follow to increase the efficiency of his travel.
Tyler should begin his travel from the state which has the lowest rating.
When he starts his travel in a country, he should visit all the states in that country before going to a different country.
Your task is to help Tyler plan his travel route and return the country and the rating of the state
Tyler will be traveling to in month M based on the rating list.
Note:
The rating list contains data for all the states together.
So the first S ratings are for country 1, the next S ratings are for country 2, and so on.
The month count starts from 1, and if two or more countries have the same lowest rating,
then choose the country whose state has the second-lowest rating.
Input Specification:
Input 1: An integer value N, representing the length of the rating list.
Input 2: An integer value S, representing the number of states in a country.
Input 3: An integer value M, representing the month number.
Input 4: An integer array A, representing the rating list.
Output Specification:
Output 1: Return the country Tyler will be traveling to in month M based on the rating list.
Output 2: Return the state Tyler will be traveling to in month M based on the rating list.
Example 1:
Input 1: 6
Input 2: 3
Input 3: 6
Input 4: {2,1,9,3,1,4}
Output 1: 2
Output 2: 4
Explanation:
There are 6 states where Tyler needs to travel, and each country has 3 states.
Based on the rating list, the route of his travel will be:
Country 1-> Country 2
(Since the lowest rating is the same in both countries,
we look at the second-lowest rating, and thus, Tyler will start his travel with Country 1)
Country 1: State with rating 1-> State with rating 2-> State with rating 9
Country 2: State with rating 1-> State with rating 3-> State with rating 4
Using this route, Tyler will be in Country 2 and State with rating 4 during the 6th month.
Therefore, 2 and 4 will be returned as output 1 and output 2, respectively.
Example 2:
Input 1: 12
Input 2: 3
Input 3: 7
Input 4: {4,5,7,9,3,2,5,1,3,2,4,1}
Output 1: 2
Output 2: 2
Explanation:
There are 12 states that Tyler needs to travel to, and each country has 3 states.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions