結果

問題 No.2372 既視感
ユーザー umezoumezo
提出日時 2023-07-09 06:45:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 2,344 ms
コンパイル使用メモリ 217,740 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-30 09:12:32
合計ジャッジ時間 3,984 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n,k,q;
  cin>>n>>k>>q;
  deque<string> deq;
  map<string,int> mp;
  while(q--){
    int c;
    cin>>c;
    if(c==1){
      string s;
      cin>>s;
      deq.push_back(s);
      mp[s]++;
      if((int)deq.size()>n){
        auto a=deq.front(); deq.pop_front();
        mp[a]--;
      }
    }
    else{
      vector<string> T(6);
      vector<int> D(6);
      rep(i,6) cin>>T[i]>>D[i];
      int cnt=0;
      int res=60;
      rep(i,6){
        if(mp[T[i]]>0){
          if(res-min(k,D[i])>=0){
            cnt++;
            res-=min(k,D[i]);
            deq.push_back(T[i]);
            mp[T[i]]++;
          }
          else break;
        }
        else{
          if(res-D[i]>=0){
            cnt++;
            res-=D[i];
            deq.push_back(T[i]);
            mp[T[i]]++;
          }
          else break;
        }
      }
      cout<<cnt<<endl;
      rep(i,cnt){
        deq.push_back(T[i]);
        mp[T[i]]++;
      }
      while(deq.size()>n){
        auto a=deq.front(); deq.pop_front();
        mp[a]--;
      }
    }
  }

  return 0;
}
0