#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector> VT(N); for(auto &[v,t] : VT) cin >> v >> t; sort(VT.begin(),VT.end(),[&](auto &a,auto &b){return a.first+a.second dp; dp.set(0); bitset<20001> d; for(auto [v,t] : VT){ d.reset(); for(int i=0; i=0; i--) if(dp.test(i)){cout << i << endl; break;} }