xuanpai:#include <bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<pair<int, int>> v(n);
for(int i = 0;i<n;i++){
scanf("%d",&v[i].first);
}
int l = 0;
for(int i = 0;i<n;i++){
scanf("%d",&v[i].second);
l+=v[i].second;
}
sort(v.begin(), v.end());
vector<int> dp(l+10,0);
int sum = 0;
int ans = 0;
for(int i = 0;i<n;i++){
for(int j = sum;j>=0;j--){
if(v[i].second*7>=j){
dp[j+v[i].second] = max(dp[j+v[i].second],dp[j]+1);
}
ans = max(ans,dp[j+v[i].second]);
}
sum+=v[i].second;
}
cout<<ans<<endl;
}
第四题ac