結果
問題 |
No.2422 regisys?
|
ユーザー |
|
提出日時 | 2024-09-04 11:19:44 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 1,394 bytes |
コンパイル時間 | 13,807 ms |
コンパイル使用メモリ | 401,808 KB |
実行使用メモリ | 20,928 KB |
最終ジャッジ日時 | 2024-09-04 11:20:06 |
合計ジャッジ時間 | 19,093 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 61 |
ソースコード
use std::collections::{BTreeSet, HashSet}; use proconio::input; fn main() { input! { n:usize, m:usize, a:[usize;n], b:[usize;n], tc:[(usize,usize);m], } let mut c_t0 = tc .iter() .filter_map(|(t, c)| if *t == 0 { Some(*c) } else { None }) .collect::<Vec<_>>(); c_t0.sort(); let mut c_t1 = tc .iter() .filter_map(|(t, c)| if *t == 1 { Some(*c) } else { None }) .collect::<Vec<_>>(); c_t1.sort(); let mut bs = BTreeSet::new(); let mut unbuy = (0..n).collect::<HashSet<_>>(); let mut ids_sort = (0..n).collect::<Vec<_>>(); ids_sort.sort_by_key(|i| a[*i]); let mut ans = 0; let mut id = 0; for &c in c_t0.iter() { while id < n && a[ids_sort[id]] <= c { bs.insert((b[ids_sort[id]], ids_sort[id])); id += 1; } if let Some(&last) = bs.last() { ans += 1; bs.remove(&last); unbuy.remove(&last.1); } } let mut b_rem = unbuy.iter().map(|i| b[*i]).collect::<Vec<_>>(); b_rem.sort_by(|x, y| y.cmp(x)); for &c in c_t1.iter() { match b_rem.last() { Some(&last) if last <= c => { ans += 1; b_rem.pop(); } _ => (), } } ans = n - ans; println!("{}", ans); }