- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find the minimum time after which one can exchange notes in Python

Suppose there are n number of cashiers exchanging the money, at the moment, the i-th cashier had ki number of people in front of him/her. Now, the j-th person in the line to i-th cashier had m[i,j] notes. We have to find how early can one exchange his/her notes. We have to keep in mind that the cashier spent 5 seconds to scan a single note.After completing scanning of every note for the customer, he/she took 15 seconds to exchange the notes.

So, if the input is like Input : n = 6, k = [12, 12, 12, 12, 12, 12]

7 | 8 | 9 | 7 | 9 | 6 | 10 | 9 | 9 | 6 | 7 | 8 |

10 | 7 | 10 | 9 | 8 | 9 | 9 | 9 | 9 | 6 | 5 | 6 |

9 | 8 | 8 | 9 | 8 | 6 | 7 | 9 | 10 | 6 | 6 | 7 |

7 | 6 | 9 | 6 | 6 | 9 | 8 | 9 | 6 | 6 | 8 | 9 |

9 | 8 | 7 | 6 | 5 | 10 | 8 | 10 | 7 | 6 | 6 | 8 |

8 | 7 | 6 | 5 | 7 | 9 | 7 | 9 | 6 | 5 | 5 | 7 |

then the output will be 585, as the cashier needs 5 secs for scanning every note of each customer, so add 5*m[I,j]. Now each cashier takes 15 seconds for every customer, so add 15*k[] to the answer. The minimum time taken after computing the time taken by each cashier will be the answer. So cashier m[5] takes the minimum time 585.

To solve this, we will follow these steps −

n := size of k

minimum := 99999

for i in range 0 to n, do

temp := k[i] * 15

for j in range 0 to k[i], do

temp := temp + m[i, j] * 5

if temp < minimum, then

minimum := temp

return minimum

## Example

Let us see the following implementation to get better understanding −

def minTimeToExchange(k, m): n = len(k) minimum = 99999 for i in range(n): temp = k[i] * 15 for j in range(k[i]): temp += m[i][j] * 5 if temp < minimum: minimum = temp return minimum k = [12, 12, 12, 12, 12, 12] m = [ [7,8,9,7,9,6,10,9,9,6,7,8], [10,7,10,9,8,9,9,9,9,6,5,6], [9,8,8,9,8,6,7,9,10,6,6,7], [7,6,9,6,6,9,8,9,6,6,8,9], [9,8,7,6,5,10,8,10,7,6,6,8], [8,7,6,5,7,9,7,9,6,5,5,7]] print(minTimeToExchange(k, m))

## Input

[12, 12, 12, 12, 12, 12], [[7,8,9,7,9,6,10,9,9,6,7,8], [10,7,10,9,8,9,9,9,9,6,5,6], [9,8,8,9,8,6,7,9,10,6,6,7], [7,6,9,6,6,9,8,9,6,6,8,9], [9,8,7,6,5,10,8,10,7,6,6,8], [8,7,6,5,7,9,7,9,6,5,5,7]]

## Output

585

- Related Questions & Answers
- Find the time which is palindromic and comes after the given time in Python
- Python Get the real time currency exchange rate?
- Find the minimum number of rectangles left after inserting one into another in C++
- How can we create a MySQL one-time event that executes after some specified time interval?
- Program to find number of sublists containing maximum and minimum after deleting only one element in Python
- Program to find minimum number colors remain after merging in Python
- Program to find minimum amplitude after deleting KLength sublist in Python
- Program to find minimum amplitude after deleting K elements in Python
- Program to find minimum time to complete all tasks in python
- Program to find minimum time to finish all jobs in Python
- Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted in Python
- Find minimum number of currency notes and values that sum to given amount in C++
- Program to find minimum possible maximum value after k operations in python
- Find the element before which all the elements are smaller than it, and after which all are greater in Python
- Program to find expected growth of virus after time t in Python