#P8286. 「DAOI R1」Ciky
「DAOI R1」Ciky
Background
She is Mine.
Problem Description
In late autumn, leaves are falling everywhere, and Ciky is very happy.
took the kids to the woods and picked up many golden leaves.
All the leaves they picked are regular polygons. Now plans to turn them into specimens, bind them into an album, and give it to Ciky.
To make one specimen, you need to color along the edge of a leaf, and the edge colors of different leaves must be different. Also, each specimen has a corresponding beauty value.
When binding the specimens into an album, the following conditions must be satisfied:
- The perimeter of the -th leaf must not be greater than the perimeter of the -th leaf.
- The beauty value of the -th leaf must not be greater than the beauty value of the -th leaf.
has pens of different colors, and the -th pen can draw a total length of .
There are leaves. The -th leaf is a regular -gon, each side has length , and its beauty value is .
More simply, only when can the -th pen be used to draw the -th leaf.
In particular, after a leaf is finished using the -th pen, its perimeter becomes . Each pen can draw at most one leaf.
hopes either to give away more specimens, or to maximize the total beauty value of the specimens made.
Note: The two questions are independent.
Input Format
The first line contains two integers, .
The second line contains integers. The -th integer denotes .
The third line contains integers. The -th integer denotes .
The fourth line contains integers. The -th integer denotes .
The fifth line contains integers. The -th integer denotes .
Output Format
There are two lines.
The first line contains one integer, the maximum possible number of specimens in the album.
The second line contains one integer, the maximum possible total beauty value of the specimens made.
Note: The second question does not require putting the specimens into the album.
5 3
9 7 2 5 6
1 2 1
2 6 8
3 3 4
3
16
Hint
Sample Explanation
For the first question, use the -th pen to draw the -st leaf, the -th pen to draw the -nd leaf, and the -st pen to draw the -rd leaf. The resulting perimeters are , so you can draw leaves.
For the second question, you can use the same method. The total beauty value is .
Constraints
This problem uses bundled testdata.
| Subtask | Score | ||
|---|---|---|---|
For of the testdata, , , , .
Translated by ChatGPT 5