complete @jungol 1006.rs 1828.rs

This commit is contained in:
2026-08-18 19:58:19 +09:00
parent 6a4ee13ce2
commit 3ea00ef740
2 changed files with 166 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
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);
}