Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

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.

added 24 characters in body; edited tags
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 478

#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)

added 157 characters in body
Source Link
Ang
  • 131
  • 1
  • 5

#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)

Source Link
Ang
  • 131
  • 1
  • 5
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /