#include<bits/stdc++.h>
#define R register
#define I inline
using namespace std;
struct node {int va,ti;} p[105];
int n,m,k,tim,ans,f[105][1005];
I int read()
{
int s=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) s=(s<<3)+(s<<1)+(c^48),c=getchar();
return s;
}
bool cmp(node a,node b) {return a.va<b.va;}
I int mn(int a,int b) {return a>b?b:a;}
I int mx(int a,int b) {return a<b?b:a;}
int main()
{
n=read(),m=read(),k=read();
for(R int i=1;i<=n;i++) p[i].va=read(),p[i].ti=read(),tim+=p[i].ti;
if(tim<=m)
{
sort(p+1,p+1+n,cmp);
for(R int i=n;i>1;i--)
{
if(k) ans+=p[i].va,k--;
ans+=p[i].va;
}
printf("%d",ans);
return 0;
}
for(R int i=1;i<=n;i++)
{
for(R int us=mn(i,k);us>0;us--)
for(R int j=m;j>=p[i].ti;j--) f[us][j]=mx(f[us][j],mx(f[us-1][j-p[i].ti]+(p[i].va<<1),f[us][j-p[i].ti]+p[i].va));
for(R int j=m;j>=p[i].ti;j--) f[0][j]=mx(f[0][j],f[0][j-p[i].ti]+p[i].va);
}
printf("%d",f[k][m]);
return 0;
}
看见很多人90分是WA了第10个点,我WA了第3个,求助!