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

17906번 - Fishmongers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB110755274.286%

문제

You fish fish.

You hate fish.

You love monies.

Therefore sell fish.

To fishmongers.

For maximum profit.

입력

The first line of input contains two integers n (1 ≤ n ≤ 100 000), the number of fish you have to sell, and m (1 ≤ m ≤ 100 000), the number of fishmongers. On the second line follows n space-separated integers w1, w2, . . . , wn, the weight of each of your fish in kilograms (1 ≤ wi ≤ 100 000). Finally, there are m lines, the j’th of which consisting of two integers xj (1 ≤ xj ≤ 100 000) and pj (1 ≤ pj ≤ 100 000), respectively indicating how many fish the j’th fishmonger wants to buy and how many monies he will pay per kilogram.

출력

A single integer, the maximum number of monies you can obtain by selling your fish to the fishmongers.

제한

예제 입력 1

4 3
1 2 7 5
2 4
1 5
3 3

예제 출력 1

66

힌트

출처

Contest > Bergen Open > Bergen Open 2018 F번

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

출처

대학교 대회

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

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