#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> N >> W; vector

a(N); for(i=0;i> v >> w; a[i].first=w; a[i].second=v; } sort(a.begin(),a.end()); int p=-1; for(i=N-1;i>=0;i--){ if(a[i].first<=W){ p=i; break; } } if(p==-1){ cout << -1 << endl; return 0; } int mx=0,q=-1; for(i=0;i<=p;i++){ if(mx