Gas and Minerals
면접 대비시간 제한1초메모리 제한1024 MB
광물과 가스 예산, 그리고 비용과 방어력을 가진 최대 10종류의 건물이 주어질 때, 각 종류를 원하는 만큼 지어 총 방어력을 최대로 만든다.
문제
An Artifact that could turn the tide of the war was discovered in one of the distant Terran colonies. Meanwhile, the intelligence service reports that a Zerg swarm is moving towards the colony. It is necessary to protect the Artifact at all costs before the arrival of reinforcements.
You have units of minerals and units of Vespen gas. In addition, there are types of defensive buildings available for construction. A building of type requires units of minerals and units of gas to construct, and increases the defenses of the base by units. You can construct any number of buildings (including zero) of any type, provided that the total costs of minerals and gas for all buildings will not exceed and , respectively.
Determine what the maximum total building defense capability can be achieved under the given constraints.
입력
The first line contains three integers , and --- the number of available units of minerals and gas, respectively, and the number of building types (, , ).
The th of the following lines contains three integers , and --- the amount of units of mineral and gas are needed to construct a building of the -th type and its defenses (, , ).
출력
Print a single integer --- the maximum total building defense capability that can be achieved.
힌트
In the first example, the optimum is provided by the construction of one building of type and one building of type .
In the second example, it is most profitable to construct one building of type and two buildings of type .