結果
問題 |
No.2422 regisys?
|
ユーザー |
|
提出日時 | 2024-09-04 11:16:11 |
言語 | Rust (1.83.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 14,348 ms |
コンパイル使用メモリ | 403,464 KB |
実行使用メモリ | 21,000 KB |
最終ジャッジ日時 | 2024-09-04 11:16:33 |
合計ジャッジ時間 | 21,440 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 WA * 27 RE * 23 |
ソースコード
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..m).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); }