結果
問題 |
No.2372 既視感
|
ユーザー |
![]() |
提出日時 | 2023-07-10 18:36:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,181 bytes |
コンパイル時間 | 865 ms |
コンパイル使用メモリ | 82,356 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-12 23:44:04 |
合計ジャッジ時間 | 1,768 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
/* -*- coding: utf-8 -*- * * 2372.cc: No.2372 既視感 - yukicoder */ #include<cstdio> #include<string> #include<unordered_map> #include<deque> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 500; const int M = 6; /* typedef */ typedef deque<string> dqs; typedef unordered_map<string,int> umsi; /* global variables */ /* subroutines */ void addp(int n, dqs &pq, umsi &pmp, string &s) { pq.push_back(s); pmp[s]++; while (pq.size() > n) { string &t = pq.front(); if (--pmp[t] == 0) pmp.erase(t); pq.pop_front(); } } /* main */ int main() { int n, k, qn; scanf("%d%d%d", &n, &k, &qn); dqs pq; umsi pmp; while (qn--) { int op; scanf("%d", &op); if (op == 1) { char s[16]; scanf("%s", s); string w(s); addp(n, pq, pmp, w); } else { string ts[M]; int sum = 0, c = 0; for (int i = 0; i < M; i++) { char t[16]; int d; scanf("%s%d", t, &d); ts[i] = string(t); sum += pmp.count(ts[i]) ? min(d, k) : d; if (sum <= 60) c++; } printf("%d\n", c); for (int i = 0; i < c; i++) addp(n, pq, pmp, ts[i]); } } return 0; }