結果

問題 No.2372 既視感
ユーザー tnakao0123tnakao0123
提出日時 2023-07-10 18:34:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,181 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 82,056 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-10 01:15:23
合計ジャッジ時間 2,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,352 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,352 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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 < M; i++)
	addp(n, pq, pmp, ts[i]);
    }
  }

  return 0;
}
0