Logo
(追記) (追記ここまで)

31103번 - Gas and Minerals 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB21201392.857%

문제

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 $m$ units of minerals and $g$ units of Vespen gas. In addition, there are $n$ types of defensive buildings available for construction. A building of type $i$ requires $a_i$ units of minerals and $b_i$ units of gas to construct, and increases the defenses of the base by $c_i$ 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 $m$ and $g,ドル respectively.

Determine what the maximum total building defense capability can be achieved under the given constraints.

입력

The first line contains three integers $m,ドル $g$ and $n$ --- the number of available units of minerals and gas, respectively, and the number of building types (0ドル \le m \le 1000,ドル 0ドル \le g \le 1000,ドル 1ドル \le n \le 10$).

The $i$ th of the following $n$ lines contains three integers $a_i,ドル $b_i$ and $c_i$ --- the amount of units of mineral and gas are needed to construct a building of the $i$-th type and its defenses (1ドル \le a_i \le 100,ドル 0ドル \le b_i \le 100,ドル 0ドル \le c_i \le 100$).

출력

Print a single integer --- the maximum total building defense capability that can be achieved.

제한

예제 입력 1

10 10 3
7 0 6
6 2 7
2 5 5

예제 출력 1

12

예제 입력 2

11 10 3
7 0 6
6 2 7
2 5 5

예제 출력 2

16

노트

In the first example, the optimum is provided by the construction of one building of type 2ドル$ and one building of type 3ドル$.

In the second example, it is most profitable to construct one building of type 1ドル$ and two buildings of type 3ドル$.

출처

Contest > Open Cup > 2020/2021 Season > Stage 16: Grand Prix of Urals G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /