$dp\left[i\right]\left[j\right]\left[k\right]:前i个瓶子中选择j个瓶子，使得这j个瓶子的容量为k，这k个瓶子的最多剩余饮料$

$f\left(n\right)=\left\{\begin{array}{cc}dp\left[i\right]\left[j\right]\left[k\right]=max\left(d\left[i-1\right]\left[j\right]\left[k\right],dp\left[i-1\right]\left[k-1\right]\left[k-b\left[i\right]\right]+a\left[i\right]\right),& j>=b\left[i\right] \\ dp\left[i\right]\left[j\right]\left[k\right]=d\left[i-1\right]\left[j\right]\left[k\right],& j \end{array}$

#include <bits/stdc++.h>
using namespace std;

int a[105], b[105], c[105], f[105][10005];
int main()
{
int n, m;scanf("%d", &n);
int sum=0, k=0;
for(int i=1; i<=n; i++){
scanf("%d", &a[i]);
sum+=a[i];
}
m=sum;//a[]的和
for(int i=1; i<=n; i++){
scanf("%d", &b[i]);
c[i]=b[i];
}
sort(c+1, c+1+n);
for(int i=n; i>=1; i--){//求k
sum-=c[i];
k++;
if(sum<=0){
break;
}
}
memset(f, -1, sizeof(f));
f[0][0]=0;
for(int i=1; i<=n; i++){
for(int j=i; j>=1; j--){
for(int k=10000; k>=b[i]; k--){
if(f[j-1][k-b[i]]!=-1){
f[j][k]=max(f[j][k], f[j-1][k-b[i]]+a[i]);
//cout<<i<<" "<<j<<" "<<k<<" "<<f[j][k]<<endl;
}
}
}
}
int mx=0;
for(int i=m; i<=10000; i++){
mx=max(mx, f[k][i]);
}

printf("%d %d\n", k, m-mx);

return 0;
}