#include using namespace std; #include using namespace atcoder; using mint=modint1000000007; using ll=long long; using P=pair; #define rep(i,N) for(int i=0;i>N; rep(i,N){ cin>>v[i].second>>v[i].first; v[i].first+=v[i].second; } sort(v,v+N); vector dp(N+1,inf); dp[0]=0; rep(i,N){ auto[s,w]=v[i]; for(int j=N-1;j>=0;--j){ if(dp[j]+w<=s)dp[j+1]=min(dp[j+1],dp[j]+w); } } ll ans=0; while(ans<=N&&dp[ans]