// #define _GLIBCXX_DEBUG #include using namespace std; #include using namespace atcoder; using ll = long long; #define rep(i,n) for (ll i = 0; i < (n); ++i) using vl = vector; using vvl = vector; using P = pair; #define pb push_back #define int long long #define double long double #define INF (ll) 3e18 // Ctrl + Shift + B コンパイル // Ctrl + C 中断 // ./m 実行 signed main(){ int n, k, q; cin >> n >> k >> q; deque deq; while(q--){ int T; cin >> T; if (T == 1){ string d; cin >> d; deq.push_back(d); } if (T == 2){ vector t(6); vl d(6); rep(i, 6) cin >> t[i] >> d[i]; int solve = 0; int time = 0; rep(i, 6){ int find = 0; for(auto x : deq) if (x == t[i]) find = 1; if (find) time += min(d[i], k); else time += d[i]; if (time <= 60) solve++; if (time <= 60) deq.push_back(t[i]); } cout << solve << endl; } while(deq.size() > n) deq.pop_front(); } }