#include using namespace std; using ll = long long; #define rep(i,n) for (int i=0;i<(int)(n);i++) int main(){ int n,p,c; cin>>n>>p>>c; vector v(n); vector w(n); rep(i,n) cin>>v.at(i)>>w.at(i); vector>> dp(n+1,vector>(n+1,vector(p+1,0))); rep(i,n){ rep(k,n){ rep(j,p){ for(ll l=1;j+l*v.at(i)<=p;l++) dp[i+1][k+1][j+l*v.at(i)]=max(dp[i+1][k+1][j+l*v.at(i)],(dp[i][k][j]+l*w.at(i)+c)); dp[i+1][k+1][j+1]=max(dp[i+1][k+1][j+1],dp[i][k+1][j+1]); dp[i+1][k+1][j+1]=max(dp[i+1][k+1][j+1],dp[i+1][k+1][j]); } } /* for(auto dd:dp.at(i+1)){ for(auto d:dd) cout<