#include using namespace std; typedef long long ll; int main() { int n; cin>>n; int v[n],w[n]; int vsum=0; int wsum=0; for (int i=0;i>v[i]>>w[i]; vsum+=v[i]; wsum+=w[i]; } int mxv; cin>>mxv; int dp[wsum+1]{}; for (int i=0;i=w[i];j--) dp[j]=max(dp[j],dp[j-w[i]]+v[i]); int mn=0; for (int i=1;i<=wsum;i++) if (dp[i]==mxv) { mn=i; break; } int mx=0; for (int i=wsum;i>=1;i--) if (dp[i]==mxv) { mx=i; break; } cout<