#![allow(unused_macros, unused_imports, dead_code)] use std::any::TypeId; use std::cmp::{max, min, Ordering, Reverse}; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; use std::mem::swap; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; mod procon_reader { use std::fmt::Debug; use std::io::Read; use std::str::FromStr; pub fn read() -> T where ::Err: Debug, { let stdin = std::io::stdin(); let mut stdin_lock = stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec = Vec::with_capacity(16); loop { let res = stdin_lock.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if !buf.is_empty() { let ret = String::from_utf8(buf).unwrap(); return ret.parse().unwrap(); } } } pub fn read_vec(n: usize) -> Vec where ::Err: Debug, { (0..n).map(|_| read::()).collect::>() } pub fn read_vec_sub1(n: usize) -> Vec { (0..n).map(|_| read::() - 1).collect::>() } pub fn read_mat(h: usize, w: usize) -> Vec> where ::Err: Debug, { (0..h).map(|_| read_vec::(w)).collect::>>() } } use procon_reader::*; ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// fn main() { let mut que = VecDeque::new(); let mut seen = BTreeMap::new(); let n = read::(); let k = read::(); let q = read::(); let mut ans =vec![]; for _qi in 0..q { let t = read::(); if t == 1 { let s = read::(); if que.len() >= n { let d = que.pop_front().unwrap(); let rem = seen[&d]; if rem == 1 { seen.remove(&d); } else { *seen.get_mut(&d).unwrap() -= 1; } } que.push_back(s.clone()); *seen.entry(s).or_insert(0) += 1; debug_assert!(que.len() <= n); continue; } let mut a = 0; let mut cum = 0; let mut ts = vec![]; for _ in 0..6 { let t = read::(); let d = read::(); let need = if seen.contains_key(&t) { min(d, k) } else { d }; cum += need; if cum <= 60 { a += 1; } ts.push(t); } for t in ts { if que.len() >= n { let d = que.pop_front().unwrap(); let rem = seen[&d]; if rem == 1 { seen.remove(&d); } else { *seen.get_mut(&d).unwrap() -= 1; } } que.push_back(t.clone()); *seen.entry(t).or_insert(0) += 1; debug_assert!(que.len() <= n); } ans.push(a); } eprintln!(); for ans in ans { println!("{}", ans); } }