Output
#Output
m
lines. i-th
line containing two space-separated integers - 0 based index of the thread which will process the i-th
job and its start time
Constraints
#Constraints 00 ≤ n ≤ 105 (number of workers)
My Approach
#My Approach
II have used a heap to represent a priority queue of the threads to determine the next worker. The workers are first prioritized by their next free time
and then by their index
. To represent these two quantities I've used the pair
in c++ stl.
#Output
m
lines. i-th
line containing two space-separated integers - 0 based index of the thread which will process the i-th
job and its start time
#Constraints 0 ≤ n ≤ 105 (number of workers)
#My Approach
I have used a heap to represent a priority queue of the threads to determine the next worker. The workers are first prioritized by their next free time
and then by their index
. To represent these two quantities I've used the pair
in c++ stl.
Output
m
lines. i-th
line containing two space-separated integers - 0 based index of the thread which will process the i-th
job and its start time
Constraints
0 ≤ n ≤ 105 (number of workers)
My Approach
I have used a heap to represent a priority queue of the threads to determine the next worker. The workers are first prioritized by their next free time
and then by their index
. To represent these two quantities I've used the pair
in c++ stl.
#Constraints 0 <=≤ n <= 10^5≤ 105 (number of workers)
0 <=≤ m <= 10^5≤ 105 (number of jobs)
0 <=≤ t <= 10^9≤ 109 (time taken for each job)
#Constraints 0 <= n <= 10^5 (number of workers)
0 <= m <= 10^5 (number of jobs)
0 <= t <= 10^9 (time taken for each job)
#Constraints 0 ≤ n ≤ 105 (number of workers)
0 ≤ m ≤ 105 (number of jobs)
0 ≤ t ≤ 109 (time taken for each job)
#Constraints 0 <= n <= 10^5 (number of workers)
0 <= m <= 10^5 (number of jobs)
0 <= t <= 10^9 (time taken for each job)
#My Approach
I have used a heap to represent a priority queue of the threads to determine the next worker. The workers are first prioritized by their next free time
and then by their index
. To represent these two quantities I've used the pair
in c++ stl.
The code exceeds time limit in certain cases, how can I optimize it? (Time limit: 1 sec)
#My Approach
I have used a heap to represent a priority queue of the threads to determine the next worker. The workers are first prioritized by their next free time
and then by their index
. To represent these two quantities I've used the pair
in c++ stl.
The code exceeds time limit in certain cases, how can I optimize it?
#Constraints 0 <= n <= 10^5 (number of workers)
0 <= m <= 10^5 (number of jobs)
0 <= t <= 10^9 (time taken for each job)
#My Approach
I have used a heap to represent a priority queue of the threads to determine the next worker. The workers are first prioritized by their next free time
and then by their index
. To represent these two quantities I've used the pair
in c++ stl.
The code exceeds time limit in certain cases, how can I optimize it? (Time limit: 1 sec)