Files
CodeObject/storage/jungol/rs/completed/1828.rs

29 lines
588 B
Rust

use std::io::{read_to_string, stdin};
fn main() {
let temp = read_to_string(stdin()).unwrap();
let mut iter = temp
.split_ascii_whitespace()
.map(|x| x.parse::<i32>().unwrap());
let n = iter.next().unwrap() as usize;
let mut chems = (0..n)
.map(|_| (iter.next().unwrap(), iter.next().unwrap()))
.collect::<Vec<_>>();
chems.sort_by_key(|x| x.1);
let mut pin = chems[0].1;
let mut cnt = 1;
for (x, y) in chems {
if x > pin {
cnt += 1;
pin = y;
}
}
println!("{}", cnt);
}