#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; int W = 100005; int main(){ int n; cin >> n; vector

wv(n); rep(i,n){ cin >> wv[i].second >> wv[i].first; } int V;cin >> V; vector> dp(n+1,vector(W,0)); for(int i=1;i<=n;i++){ rep(j,W){ if(j - wv[i-1].first >=0){ dp[i][j] = max(dp[i-1][j],dp[i-1][j-wv[i-1].first] + wv[i-1].second); }else{ dp[i][j] = dp[i-1][j]; } } } int mn = INF; int mx = 0; for(int j=1;j