#pragma GCC optimize("Ofast") #include using namespace std; using i64=int_fast64_t; using pii=pair; using pll=pair; template constexpr T inf=numeric_limits::max() / (T)2; template using heap=priority_queue; template using minheap=priority_queue,greater>; #define fir first #define sec second #define mkp make_pair #define mkt make_tuple #define emb emplace_back #define emp emplace #define all(v) begin(v),end(v) namespace std { template void hash_combine(size_t &seed, T const &key) { seed ^= hash()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } template struct hash> { size_t operator()(pair const &pr) const { size_t seed = 0; hash_combine(seed,pr.first); hash_combine(seed,pr.second); return seed; } }; } void ios_untie() { ios::sync_with_stdio(false); cin.tie(nullptr); } void file_setup() { if(!freopen("stderr.txt","wt",stderr)) { std::cerr << "Failed to open the stderr file\n"; freopen("CON","wt",stderr); } if(!freopen("stdout.txt","wt",stdout)) { std::cerr << "Failed to open the stdout file\n"; freopen("CON","wt",stdout); } if(!freopen("stdin.txt","rt",stdin)) { std::cerr << "Failed to open the stdin file.\n"; freopen("CON","rt",stdin); } } template void init(A (&array)[N], const T &val) { fill((T*)array,(T*)(array + N),val); } i64 binry(i64 ok, i64 ng, const function &f) { while(abs(ok-ng)>1) { i64 mid=(ok+ng)/2; (f(mid) ? ok : ng) = mid; } return ok; } /*-------------------------------*/ int n; pii ie[10010]; bool dp[20010]; void solve() { sort(ie,ie+n,[](pii a, pii b)->bool{ return a.fir+a.sec=0; --j) { dp[j+v]|=dp[j]; } } int ans=0; for(int i=0; i<=20000; ++i) { if(dp[i]) { ans=i; } } cout<>n; for(int i=0; i>ie[i].fir>>ie[i].sec; } solve(); }