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

7130번 - Milk and Honey 다국어

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

문제

In the country of milk and honey, Juku is in charge of cows and bees. Since bees will sting cows and make them unhappy and cows will eat all the flowers bees use to make honey, cows and bees need to be kept on separate fields.

Each field can support a limited number of animals. Cows and bees are free to obtain, so as many will be put on any field as can be supported there.

Each cow produces one unit of milk and each bee produces one unit of honey. Milk and honey produce different levels of happiness when consumed.

Juku's task is to choose how to place cows and bees in the milk and honey land to maximize happiness. Juku needs your help to do this since the calculations are too many to be done on a piece of paper.

입력

The first line of inputcontains two integers: $M$ (0ドル \le M \le 1000$), the amount of happiness per unit of milk, and $H$ (0ドル \le H \le 1000$), the amount of happiness per unit of honey.

The second line contains $N$ (1ドル \le N \le 1000$), the number of fields. The following $N$ lines describe the fields. Each line contains $C$ (0ドル \le C \le 100$) and $B$ (0ドル \le B \le 100$), the number of cows and the number bees the field can support.

출력

The only line of output should contain a single number, the maximum amount of happiness achievable.

제한

예제 입력 1

3 5
3
4 2
3 2
2 1

예제 출력 1

28

The optimal plan is to put cows on the first, bees on the second, and cows on the third field, producing 4ドル \cdot 3 + 2 \cdot 5 + 2 \cdot 3 = 28$ units of happiness in total.

힌트

출처

Olympiad > Estonian Informatics Olympiad > 2016-17 > Final Round > Basic 1번

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

출처

대학교 대회

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

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