complete @jungol 1006.rs 1828.rs
This commit is contained in:
28
storage/jungol/rs/completed/1828.rs
Normal file
28
storage/jungol/rs/completed/1828.rs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user