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 Haskell (GHC 7.10.3) (judge verdict: Accepted)

-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE ScopedTypeVariables #-}
-- {-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE ViewPatterns #-}
-- {-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
-- import qualified Data.Vector.Algorithms.Merge as VAM
-- import qualified Data.Heap as HP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

--------------------------------------------------------------------------
solve xys time
    | VU.null xys = "Yes"
    | time + cos <= lim = solve (VU.tail xys) (time + cos)
    | otherwise = "No"
    where
        (lim,cos) = VU.head xys

main = do
    n <- int
    xys <- VU.fromList . sort . VU.toList . VU.map swap <$> multipleLinesToTupleV n
    putStrLn $ solve xys 0
--------------------------------------------------------------------------

-- Input Util
int :: IO Int
int = readLn 

double :: IO Double
double = readLn 

str :: IO String
str = getLine

strBC :: IO BC.ByteString
strBC = BC.getLine

singleLineToIntL :: IO [Int]
singleLineToIntL = getLine >>= return . map read . words

singleLineToDoubleL :: IO [Double]
singleLineToDoubleL = getLine >>= return . map read . words

singleLineToIntV :: Int -> IO (VU.Vector Int)
singleLineToIntV n = BC.getLine >>= return . VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace)

singleLineToDoubleV :: Int -> IO (VU.Vector Double)
singleLineToDoubleV n = BC.getLine >>= return . VU.fromList . map (read . BC.unpack) . BC.words

multipleLinesToIntL :: Int -> IO [Int]
multipleLinesToIntL n = replicateM n readLn

multipleLinesToDoubleL :: Int -> IO [Double]
multipleLinesToDoubleL n = replicateM n readLn

multipleLinesToIntV :: Int -> IO (VU.Vector Int)
multipleLinesToIntV n = VU.replicateM n readLn

multipleLinesToDoubleV :: Int -> IO (VU.Vector Double)
multipleLinesToDoubleV n = VU.replicateM n (BC.getLine >>= return . read . BC.unpack)

multipleLinesToTupleL :: Int -> IO [(Int, Int)]
multipleLinesToTupleL n = replicateM n (getLine >>= return . (\[a,b] -> (a,b)) . map read . words)

multipleLinesToTupleV :: Int -> IO (VU.Vector (Int, Int))
multipleLinesToTupleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, _) = BC.readInt $ BC.dropWhile isSpace bs'
    return (a,b)

-- others
strToChr :: String -> Char
strToChr [x] = x

chrToStr :: Char -> String
chrToStr x = [x]

m1 :: Int -> Int
m1 x = subtract 1 x

toDouble :: Int -> Double
toDouble x = fromIntegral x

toInt :: Double -> Int
toInt x = floor x