QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3937. 鱼贩

統計

你捕鱼。 你讨厌鱼。 你爱钱。 所以卖鱼。 卖给鱼贩子。 为了获得最大利润。

CC0, by Geir Fløde via Pixabay

输入格式

输入的第一行包含两个整数 $n$ ($1 \le n \le 100\,000$),表示你拥有的鱼的数量,以及 $m$ ($1 \le m \le 100\,000$),表示鱼贩子的数量。第二行包含 $n$ 个空格分隔的整数 $w_1, w_2, \dots, w_n$,表示每条鱼的重量(单位:千克,$1 \le w_i \le 100\,000$)。最后有 $m$ 行,其中第 $j$ 行包含两个整数 $x_j$ ($1 \le x_j \le 100\,000$) 和 $p_j$ ($1 \le p_j \le 100\,000$),分别表示第 $j$ 个鱼贩子想要购买的鱼的数量,以及他愿意支付的每千克单价。

输出格式

输出一个整数,表示通过将鱼卖给鱼贩子所能获得的最大金额。

样例

输入 1

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

输出 1

66

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.