1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! solution for <https://atcoder.jp/contests/abc131/tasks/abc131_d>

use lib::util::io::Yes;
use lib::util::vec::*;
use lib::*;
use paste;
use proconio::input;

pub fn abc131_d() {
    input! {
        n: usize,
        mut ab: [(usize, usize); n]
    }
    unzip!((a, b), ab);

    srt!(b.smaller(), a, b);
    let mut ok = true;
    let mut c = 0;

    for i in 0..n {
        ok &= c + a[i] <= b[i];
        c += a[i];
    }
    Yes(ok);
}