题意:从n个物品买k个,此时有m个优惠,对于一个一次性买了x个物品,可以免费这x中最便宜的y个物品。
思路:枚举取每种优惠最低值,dp
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int maxn = 2e5+5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int p[maxn];
ll dp[2005];
int main(){
IO;
ll n,m,k;cin>>n>>m>>k;
vector<int>a(n);
forn(i,n) cin>>a[i];
sort(a.begin(),a.end());
vector<ll>sum(k+1);
sum[0] = 0;
for1(i,k) sum[i] = a[i-1]+sum[i-1];
a.resize(k);
for1(i,m){
int x,y;cin>>x>>y;
p[x] = max(p[x],y);
}
for1(i,k) dp[i] = sum[i];
for1(i,k){
for1(j,i)if(p[j]){
dp[i] = min(dp[i],dp[i-j]+sum[i]-sum[i-j+p[j]]);
}
}
cout<<dp[k]<<'
';
return 0;
}