Challenge overview
Hello and welcome to the challenge!
In this challenge you have to schedule your tasks. This time you'll use the Shortest Job First algorithm. In this way, you perform tasks from the shortest to the longest. Additionally, in your set of tasks is one "Special task" and your goal is to calculate how many hours you need to end this task. If the jobs take the same time then it is First In First Out (FIFO).
Input
- The first line of the standard input contains the number of tasks you have (N).
- The second line contains
N
integerst1, t2,..., tN
(separated by a single space), denoting the number of hours you need to do each task. - The third line contains one integer denoting index (
i
) of the "Special Task" (zero-indexed).
Output
- To the standard output print one integer denoting the number of hours you need to do "Special Task"
Constraints
0 < N <= 25
0 < t1, t2,..., tN <= 100
0 <= i < N
You can solve this programming contest in C#, C++, Java, Ruby, JavaScript, Python, PHP and many more languages. If you want, you can also take part in other Challenges. Below you can find some of them:
Did you like this challenge and would like to try your hand at some interesting big programming competitions? Check what’s all over the news in tech world in June 2019 in our article with upcoming IT Conferences, Hackathons and Online Challenges in July 2019.
Have fun and good luck! :)