結果

問題 No.2804 Fixer And Ratism
ユーザー primenumber11
提出日時 2024-07-11 23:12:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 3,527 ms
コンパイル使用メモリ 268,664 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-07-11 23:13:04
合計ジャッジ時間 7,728 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  //人を並べるためのpriority_queue
  priority_queue<pair<int,string>, vector<pair<int,string>>, greater<pair<int,string>>> que;
  //使用可能にしたかどうかを管理するmap
  map<string,bool> mp;
  for(int i = 0;i < Q; i++) {
    int q;
    cin >> q;
    if(q == 1) {
      string s;
      int r;
      cin >> s >> r;
      mp[s] = false;
      que.push({r, s});
    }
    if(q == 2) {
      int x;
      cin >> x;
      N -= x;
    }
    if(q == 3) {
      string s;
      int x;
      cin >> s >> x;
      mp[s] = true;
      N += x;
    }
    if((q == 1 || q == 2) && (int)que.size() > N) {
      set<pair<int,string>> S;
      while((int)que.size() > N) {
        if(mp[que.top().second] == true && que.top().first <= 4000) {
          que.push({que.top().first + 4000, que.top().second});
          que.pop();
        }
        else {
          S.insert({que.top().first%4000,que.top().second});
          que.pop();
        }
      }
      for(auto j : S) {
      	cout << j.second << endl;
      }
    }
  }
}
0