Problem:
Score: 400 points

Problem Statement

Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.

Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.

It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.

Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.

Can Kizahashi complete all the jobs in time? If he can, print Yes; if he cannot, print No.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N
A_1 B_1
.
.
.
A_N B_N

Output

If Kizahashi can complete all the jobs in time, print Yes; if he cannot, print No.

Sample Input 1

5
2 4
1 9
1 8
4 9
3 12

Sample Output 1

Yes

He can complete all the jobs in time by, for example, doing them in the following order:

Do Job 2 from time 0 to 1.

Do Job 1 from time 1 to 3.

Do Job 4 from time 3 to 7.

Do Job 3 from time 7 to 8.

Do Job 5 from time 8 to 11.

Note that it is fine to complete Job 3 exactly at the deadline, time 8.

Sample Input 2

3
334 1000
334 1000
334 1000

Sample Output 2

No

He cannot complete all the jobs in time, no matter what order he does them in.

Sample Input 3

30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720

Sample Output 3

Yes

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

	#pragma GCC optimize("Ofast")
	#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
	#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp> // Common file  
	#include <ext/pb_ds/tree_policy.hpp>  
	#include <functional> // for less  
	#include <iostream>  
	using namespace __gnu_pbds;  
	using namespace std;
	#define ll long long
	typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
	using namespace std;
	 
	#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
	#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
	#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
	#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
	#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
	#define fill(ar,val) memset(ar, val, sizeof(ar))
	#define fill0(ar) fill((ar), 0)
	#define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF
	#define debug(x) cout<<#x<<": "<<x<<endl
	#define arr1d(a,n) cout << #a << " : "; fr(_,1,n) cout << a[_] << ' '; cout << endl;
	#define arr1d0(a,n) cout << #a << " : "; rep(_,n) cout << a[_] << ' '; cout << endl;
	#define arr2d(a,n,m) cout << #a << " :" << endl; fr(_,1,n) {fr(__,1,m) cout << a[_][__] << ' '; cout << endl;}
	#define arr2d0(a,n,m) cout << #a << " :" << endl; rep(_,n) {rep(__,m) cout << a[_][__] << ' '; cout << endl;}
	/*Author Ritick Goenka || ritick(codechef) ||ritick(codeforces) */
	/*IIT Roorkee = <3 */
	#define ull unsigned long long
	#define ld long double
	#define ui unsigned int
	#define all(ar) ar.begin(), ar.end()
	#define pb push_back
	#define mp make_pair
	#define ff first
	#define ss second
	#define y0 yyyyyy0
	auto clk=clock();
	#define y1 yyyyyy1
	#define setb __builtin_popcount
	#define BIT(n) (1<<(n))
	#define SQR(x) ((x) * (x))
	#define CUBE(x) ((x) * (x) * (x))
	#define LSOne(S) (S) & (-S)
	inline bool EQ(double a, double b) {return fabs(a - b) < 1e-9;}
	 
	typedef pair<int, int> ii;
	typedef pair<int, ii> iii;
	typedef vector<ii> vii;
	typedef vector<int> vi;
	typedef vector<string> vs;
	 
	template<typename T>inline T gcd(T a, T b){if (b == 0)return a;else return gcd(b, a % b);}
	// template<typename T>inline T lcm(T a, T b){return (a * b) / gcd(a, b);}
	template<typename T> string toStr(T x) {stringstream st; st << x; string s; st >> s; return s;}
	template<class T>
	void splitStr(const string &s, vector<T> &out)
	{
	    istringstream in(s);
	    out.clear();
	    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
	}
	 
	inline int two(int n) {return 1 << n;}
	inline int isOnBit(int n, int b) {return (n >> b) & 1;}
	inline void onBit(int & n, int b) {n |= two(b);}
	inline void offBit(int & n, int b) {n &= ~two(b);}
	inline int lastBit(int n) {return n & (-n);}
	inline int cntBit(int n) {int res = 0; while(n && ++res) n -= n &(-n); return res;}
	 
	const int dx4[] = {-1, 0, 1, 0};
	const int dy4[] = {0, 1, 0, -1};
	const int dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
	const int dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
	 
	#define INP "test.inp"
	#define OUT "test.out"
	 
	#define PI 3.1415926535897932385
	#define INF 10000000000000000ll
	#define EPS 1e-7
	#define MAXN 100000
	#define MOD 1000000007
	#define dec decr
	#define endl '\n'
	 
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ll gcd(ll a, ll b) 
	{ 
	    if (a == 0) 
	        return b; 
	    return gcd(b % a, a); 
	} 
	ll modexp(ll x, ll y, ll p)
	{
	    ll res = 1;   
	    x = x % p;  
	    while (y > 0)
	    {
	        if (y %2==1)    
	            res = (res*x) % p;
	        y = y>>1;     
	        x = (x*x) % p; 
	    }
	    return res;
	}
	 ll find(ll x,ll y,ll z)
	 {
	 	ll n=x;
	 	if(x%z!=0)
	 		n=x+(z-x%z);
	 	if(n>y)
	 		return 0;
	 	ll ans=1;
	 	ll p=y-n;
	 	return p/z+1;
	 }
	int main () 
	{
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout<<fixed;
	    cout<<setprecision(9);
	    #ifdef rg
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	    #endif
	    ll n;
	    cin>>n;
	    vector<pair<ll,ll>>v;
	    rep(i,n)
	    {
	    	ll x,y;
	    	cin>>x>>y;
	    	v.pb(mp(y,x));
	    }
	    sort(all(v));
	    ll tim=0;
	    for(auto x:v)
	    {
	    	tim+=x.ss;
	    	if(tim>x.ff)
	    	{
	    		cout<<"No";
	    		return 0;
	    	}

	    }
	    cout<<"Yes";


	    #ifdef rg
	    cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	    #endif
	    return 0;
	}