Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
Tasks are (duration, deadline): (4, 2), (2, 1), (3, 2), (1, 1), (5, 3), and a single machine runs them one at a time from time 0. What is the maximum number of tasks that can finish by their deadlines?
- A. 1
- B. 2
- C. 0
- D. 5
Correct answer: A. 1
Process tasks in deadline order and, whenever the running total overruns, drop the longest task so far (a heap of durations). This exchange keeps as many tasks as possible.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the sum of gcd(a, b) over all unordered pairs of distinct elements of [6, 10, 15]?
- How many contiguous subarrays of [2, 4, 2, 1, 3] have a sum exactly equal to twice their maximum?
- With coins of denominations 1, 5, 6 and 9, what is the minimum number of coins needed to make the amount 15?
- Including the empty prefix (sum 0), how many of the prefix sums of [3, 1, 4, 2, 6, 5, 3, 1] are divisible by 4?
- How many distinct residues modulo 7 are produced by x y for x and y ranging over {2, 3, 4} (all ordered pairs, including x = y)?
- How many pairs i < j in [4, 1, 5, 2, 3] satisfy a[i] > a[j] and every element strictly between them is at most a[i]?