#C5651. Task Selection for Maximum Points

    ID: 49324 Type: Default 1000ms 256MiB

Task Selection for Maximum Points

Task Selection for Maximum Points

Nina has two types of tasks: Regular and Special. Each Regular task gives m points and each Special task gives k points. However, each task takes some time: a Regular task takes u time units and a Special task takes v time units.

You are given a total available time t, and limitations on the maximum number of tasks you can perform: at most reg Regular tasks and spec Special tasks. Your goal is to find the optimal combination of Regular and Special tasks that maximizes Nina's total score, without exceeding the total time t.

The score is computed as:

\[ \text{score} = m \times (\text{number of Regular tasks}) + k \times (\text{number of Special tasks}) \]

Determine the number of Regular and Special tasks to perform. If no valid tasks can be done within the time limit, output 0 for both.

inputFormat

The input consists of a single line containing 7 space-separated integers:

  • t (total available time)
  • m (points per Regular task)
  • k (points per Special task)
  • reg (maximum number of Regular tasks)
  • spec (maximum number of Special tasks)
  • u (time required for one Regular task)
  • v (time required for one Special task)

outputFormat

Output two space-separated integers on a single line: the first is the number of Regular tasks and the second is the number of Special tasks that yield the maximum total score under the given constraints.

## sample
100 3 6 5 3 15 30
0 3

</p>