# Untitled

unknown
plain_text
a year ago
2.4 kB
1
Indexable
Never
```Advertisement Schedule

However, they only has 1 electric board to display the advertisement, hence they should select the time to display advertisements so that visitors can watch them as much as possible.

When visitors watch advertisement, they can get points which calculated as below :

1. Three Ads  have length L1, L2, L3 and the points a person can get after watched them P1, P2, P3.

2. A visitor can get the point of a Ads  only when he/she watch the Ads  fully (from beginning to the end of that Ads )

3. When a visitor watch more than one Ads  and also get the point for them, only the Ads  with highest point will be given to that person.

4. Only one Ads  can be displayed on electric board at a time (But the next Ads  can be displayed right after the previous one ended)

Given the length of each Ads L1, L2, L3 and the point gained for them P1, P2, P3, the arrival time of each visitor into the shop and the time duration that he/she stay in the shop, write a program to select advertisement display time so that as many points as possible can be given to visitors. Print out the total sum of points that the visitors can get.

There are many way to arrange the display time, and the method above give us the maximum sum of points which visitors can get, so the answer in this case is 12.

[Constraints]

- The number of visitors N (1 ≤ N ≤ 50)

- The arrival time Ai, the time duration Di of each visitor and the length of each Ads L1, L2, L3 are given as integers (1 ≤ Ai, Di, L1, L2, L3 ≤ 50)

- Ai + Di ≤ 50

- L1 + L2 + L3 ≤ 50

- The starting time of an Ads : 1 ≤ starting time ≤ 50

- P1, P2, P4 are integers (1 ≤ P1, P2, P3 ≤ 1000)

[Input]

The 1st line given T - the total number of TC (T ≤ 50)

In each TC :

- The 1st line contains N, L1, L2, L3, P1, P2, P3 in this order

- The next N lines : each line gives the arrival time Ai and time duration Di of each visitor

5                         // Number of test cases T=5

7 1 2 3 1 2 3         // Test case 1 N=7, L1=1, L2=2, L3=3, P1=1, P2=2, P3=3

2 2                       // A1 = 2, D1 = 2

6 4                       // ...

3 3

7 2

1 1

2 1

1 10

4 3 2 1 6 4 3

1 5

1 3

2 4

2 2

...

Case #1

12

Case #2

18

Case #3

17

Case #4

16

Case #5

17998```