|
|
|
|
@ -2,7 +2,29 @@
|
|
|
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
const int N = 100010;
|
|
|
|
|
long long a[N];
|
|
|
|
|
pair<int, int> p[N];
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
int n, k, m;
|
|
|
|
|
while (~scanf("%d%d%d", &n, &k, &m))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i <= n; i++)
|
|
|
|
|
scanf("%lld", a + i), a[i] += a[i - 1];
|
|
|
|
|
for (int i = 0; i < m; i++)
|
|
|
|
|
scanf("%d%d", &p[i].first, &p[i].second);
|
|
|
|
|
sort(p, p + m);
|
|
|
|
|
priority_queue<int> h;
|
|
|
|
|
long long ans = 0;
|
|
|
|
|
for (int i = 0; i < m; i++)
|
|
|
|
|
{
|
|
|
|
|
h.push(-p[i].second);
|
|
|
|
|
if (h.size() < k) continue;
|
|
|
|
|
if (h.size() > k) h.pop();
|
|
|
|
|
ans = max(ans, a[-h.top()] - a[p[i].first - 1]);
|
|
|
|
|
}
|
|
|
|
|
printf("%lld\n", ans);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|