結果
問題 |
No.2372 既視感
|
ユーザー |
![]() |
提出日時 | 2023-06-24 11:26:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,225 bytes |
コンパイル時間 | 2,263 ms |
コンパイル使用メモリ | 205,480 KB |
最終ジャッジ日時 | 2025-02-15 01:53:32 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
// O(QlogN) 解法 #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int N, K, Q; cin >> N >> K >> Q; deque<string> A; multiset<string> B; for (int i = 0; i < Q; i++) { int q; cin >> q; if (q == 1) { string s; cin >> s; A.push_back(s); B.insert(s); } else { while ((int)A.size() > N) { B.erase(B.find(A.front())); A.pop_front(); } vector<string> solved; int ans = 0; int sum_d = 0; for (int k = 0; k < 6; k++) { string t; int d; cin >> t >> d; if (B.find(t) != B.end()) { d = min(d, K); } sum_d += d; if (sum_d <= 60) { ans++; solved.push_back(t); } } for (auto t : solved) { A.push_back(t); B.insert(t); } cout << ans << '\n'; } } return 0; }