#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int a[N], c[N], t[N], n, m, k, p, res, tmp, pos;
bool mark;
struct node
{
int v, w;
} e[N];
bool cmp(node a, node b)
{
return a.w > b.w;
}
int get_milk(int sum)
{
int tot = 0, g;
while (true)
{
g = e[p].v - t[p];
if (sum >= g)
sum -= g, tot += g * e[p].w, p++;
else
{
t[p] += sum, tot += sum * e[p].w;
return tot;
}
if (p > m)
return -1;
}
return tot;
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= m; i++)
cin >> e[i].v >> e[i].w;
for (int i = 1; i <= k; i++)
cin >> c[i];
sort(a + 1, a + 1 + n, greater<int>());
sort(c + 1, c + 1 + k, greater<int>());
sort(e + 1, e + 1 + m, cmp), p = 1;
for (int i = 1; !mark && i <= n; i++)
{
tmp = max(c[n - i + 1], get_milk(a[i]));
if (tmp == c[n - i + 1])
mark = true, pos = i + 1;
res += tmp;
}
for (int i = pos; i <= n; i++)
res += c[n - i + 1];
cout << res << endl;
}
发现评论区还有一个WA#4#5的,但是没有人给出有意义答复