Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
Four unit-time jobs given as (deadline, profit) are (4, 20), (1, 10), (1, 40), (1, 30). Each job must finish by its deadline and only one runs per time unit. What is the maximum total profit achievable?
- A. 60
- B. 70
- C. 100
- D. 50
Correct answer: A. 60
Process jobs by decreasing profit and place each in the latest free slot not after its deadline (a greedy with exchange argument). Only one deadline-1 job fits, so the 40 is taken and 30 and 10 are dropped.
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 length of the shortest contiguous subarray which, if sorted in place, makes the whole array [2, 6, 4, 8, 10, 9, 15] sorted?
- What is the number of trailing zeros in the decimal representation of the product 10 25 4 15 50?
- How many distinct sums appear over all non-empty contiguous subarrays of [2, 1, 3, 1]?
- Ropes of lengths 4, 3, 2 and 6 must be joined pairwise into one rope; joining costs the sum of the two lengths and you may join any two…
- How many distinct palindromic strings of length 3 occur as subsequences of "abcba"?
- How many unordered pairs of words in ["listen", "silent", "enlist", "google", "gogole", "cat", "act"] are anagrams of each other?