Problem 45416. Don't be Greedy!
A list of assignments is given to the students along with the submission deadlines. Each of the assignment contains particular marks.
If the student can submit a particular assignment within its deadline, he'll get marks.
But he can submit only one assignment per day.
For instance,
Assignment = [ a1, a2, a3, a4, a5, a6] Marks = [ 60,100, 20, 40, 20, 10] Deadline = [ 2, 1, 3, 2, 1, 3]
Now, on the 1st day - he can submit one among all the assignments. But in the 2nd day, he can no longer submit a2 & a5.
He wants to achieve maximum marks by carefully submitting those assignments within the deadlines. Can u help him?
The answer should be - [a2,a1,a3]. Since by submitting in this sequence, he can get the maximum marks.
Solution Stats
Problem Comments
-
8 Comments
I think the solution is not unique.
can u tell me where/which test suite u're facing problem?
cz I think the solution should be unique since there is only one parameter.
In the test2. Why [7 3 4 5 6] is not right?
ok..i see..
if there are more than one possibilities..they should be placed in sorted manner. that should do it
sorted?[3 4] or [4 3] in test2?
sorted based on the marks --
[40,50] == [4,3]
found it difficult but fun :)
The problem is not difficult, but the test suite should accept all possible solutions since there is not an unique order, for instance at test cases #2 and #4. Sorting values increases this problem's difficulty since there may be several works with the same (or complementary) weight that can be done to achieve the same score (a proper description should be added to the problem since there may cases which are not trivial to sort).
PS: In this problem when any two works have the same deadline, but their marks differ, the lowest mark should come first (which seems weird). And no explanation is given for two works that have the same deadline and mark (but at least there isn't a case at the test suite).
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
605 Solvers
-
60 Solvers
-
208 Solvers
-
316 Solvers
-
what's my tax amount this year ?
73 Solvers
More from this Author165
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!