結果

問題 No.2804 Fixer And Ratism
ユーザー tanaka255tanaka255
提出日時 2024-07-12 22:00:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 2,855 ms
コンパイル使用メモリ 233,400 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-07-12 22:00:35
合計ジャッジ時間 5,787 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 15 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 30 ms
5,376 KB
testcase_07 AC 10 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 26 ms
5,376 KB
testcase_12 AC 20 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 23 ms
5,376 KB
testcase_17 AC 10 ms
5,376 KB
testcase_18 AC 32 ms
5,632 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 33 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 40 ms
5,504 KB
testcase_24 AC 34 ms
5,504 KB
testcase_25 AC 41 ms
5,632 KB
testcase_26 AC 37 ms
5,760 KB
testcase_27 AC 34 ms
5,632 KB
testcase_28 AC 41 ms
5,632 KB
testcase_29 AC 38 ms
5,632 KB
testcase_30 AC 39 ms
5,632 KB
testcase_31 AC 36 ms
5,632 KB
testcase_32 AC 39 ms
5,632 KB
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template<typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void solve();
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int t = 1;
  //cin >> t;
  while (t--) {
    solve();
  }
}
int N,Q;
map<string,int>mp;
void solve() {
  cin>>N>>Q;
  vector<vector<pair<int,string>>>ans(Q);
  set<tuple<int,int,string>>st;
  rep(t,Q){
    int qt;cin>>qt;
    if(qt==1){
      string s;int r;cin>>s>>r;
      mp[s]=r;
      st.insert({0,r,s});
    }
    if(qt==2){
      int x;cin>>x;
      N-=x;
    }
    if(qt==3){
      string s;int x;cin>>s>>x;
      N+=x;
      st.erase({0,mp[s],s});
      st.insert({1,mp[s],s});
    }
    while(N<(int)st.size()){
      auto[_,r,s]=*st.begin();
      st.erase(st.begin());
      ans[t].emplace_back(r,s);
    }
  }
  rep(t,Q){
    sort(ans[t].begin(),ans[t].end());
    for(auto[r,s]:ans[t])cout<<s<<'\n';
  }
}
0