Skip to content

Commit d89495b

Browse files
authored
Readme.md
Problem Description of Heap Build Problem
1 parent c8277c6 commit d89495b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Data Structures/Heap/Readme.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
********Problem Description:********
2+
3+
******Task:******
4+
5+
You have a program which is parallelized and uses 𝑛 independent threads to process the given list
6+
of 𝑚 jobs. Threads take jobs in the order they are given in the input. If there is a free thread,
7+
it immediately takes the next job from the list. If a thread has started processing a job, it doesn’t
8+
interrupt or stop until it finishes processing the job. If several threads try to take jobs from the list
9+
simultaneously, the thread with smaller index takes the job. For each job you know exactly how long
10+
will it take any thread to process this job, and this time is the same for all the threads. You need to
11+
determine for each job which thread will process it and when will it start processing.
12+
13+
******Input Format:******
14+
15+
The first line of the input contains integers 𝑛 and 𝑚.
16+
The second line contains 𝑚 integers 𝑡𝑖 — the times in seconds it takes any thread to process 𝑖-th job.
17+
The times are given in the same order as they are in the list from which threads take jobs.
18+
Threads are indexed starting from 0.
19+
Constraints. 1 ≤ 𝑛 ≤ 105
20+
; 1 ≤ 𝑚 ≤ 105
21+
; 0 ≤ 𝑡𝑖 ≤ 109
22+
.
23+
24+
******Output Format:******
25+
26+
Output exactly 𝑚 lines. 𝑖-th line (0-based index is used) should contain two spaceseparated
27+
integers — the 0-based index of the thread which will process the 𝑖-th job and the time in
28+
seconds when it will start processing that job.

0 commit comments

Comments
 (0)