## DMOPC '14 Contest 3 P6 - Not Enough Time!

View as PDF

Points: 10 (partial)
Time limit: 1.4s
Memory limit: 64M

Author:
Problem type

Amagi Brilliant Contests runs a business making and hosting contests on its online platform for competitive programmers who want to run their own contests.

After several weeks and dozens of contests later, word got around about how great Amagi Brilliant Contests was, and now ABC is facing an unforeseen problem: business is booming and it has too many potential customers who wish to purchase problemsets!

For each of the customers, there are three possible problemsets to sell to them: Poor, Average, Good. Each problemset has two attributes: , the preparation time, in minutes, and , the monetary worth of the problemset, in dollars. Of course, the names of the problemsets imply that and .

While Amagi Brilliant Contests wants to provide each customer with a Good problemset, it has strict deadlines to meet — namely, ABC has at most minutes in total to prepare problemsets for their customers. In this state of emergency, the management has decided that if necessary, they will sell some of the Poor and Average problemsets in order to make the most money. Sometimes, ABC will even have to turn customers down, if selling to them won't let ABC make the most money.

You are the head of the optimization problems department at Amagi Brilliant Contests, and so you have been tasked with determining the maximum profit ABC can make.

#### Constraints

For each problemset,

For test cases worth 25% of the total marks, .

For test cases worth an additional 25% of the total marks, .

#### Input Specification

The first line of input will have , separated by a single space.

The next lines each contain six integers: for the problemsets offered to that customer.

#### Output Specification

The first and only line of output should contain the maximum amount of money ABC can earn from the customers.

#### Sample Input 1

2 300
100 10 200 20 300 30
100 20 400 80 600 120

#### Sample Output 1

40

#### Explanation for Sample Output 1

ABC will give the first customer an Average problemset and the second customer a Poor problemset. 40 dollars is the most money ABC can make from these two customers.

#### Sample Input 2

2 250
100 30 150 30 200 30
50 5 200 10 400 15

#### Sample Output 2

35

#### Explanation for Sample Output 2

One way to obtain 35 dollars is to give the first customer a Good problemset and the second customer a Poor problemset.

• commented on Oct. 31, 2020, 7:18 a.m.

You have some nice variable names there. https://dmoj.ca/submission/3101910

• commented on Dec. 27, 2017, 3:32 a.m.

How do I fix out of memory error?

• commented on Jan. 28, 2019, 7:55 p.m. edit 2

Concerning this problem, you only care about the previous DP state. Therefore, there is no need to have an array by size. or by array with modulo operations to check for previous DP state will suffice.

• commented on Oct. 31, 2020, 3:18 a.m. edited

I have an array of size .