結果

問題 No.2804 Fixer And Ratism
ユーザー primenumber11primenumber11
提出日時 2024-07-04 18:09:15
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 4,306 ms
コンパイル使用メモリ 303,308 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-11 23:11:15
合計ジャッジ時間 7,708 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 37 ms
6,940 KB
testcase_04 AC 23 ms
6,944 KB
testcase_05 AC 10 ms
6,940 KB
testcase_06 AC 70 ms
6,940 KB
testcase_07 AC 23 ms
6,940 KB
testcase_08 AC 25 ms
6,944 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 18 ms
6,944 KB
testcase_11 AC 63 ms
6,940 KB
testcase_12 AC 52 ms
6,944 KB
testcase_13 AC 13 ms
6,940 KB
testcase_14 AC 51 ms
6,944 KB
testcase_15 AC 6 ms
6,940 KB
testcase_16 AC 57 ms
6,940 KB
testcase_17 AC 22 ms
6,940 KB
testcase_18 AC 92 ms
6,944 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 8 ms
6,940 KB
testcase_21 AC 81 ms
6,940 KB
testcase_22 AC 5 ms
6,940 KB
testcase_23 AC 135 ms
6,940 KB
testcase_24 AC 132 ms
6,944 KB
testcase_25 AC 135 ms
6,940 KB
testcase_26 AC 132 ms
6,940 KB
testcase_27 AC 133 ms
6,944 KB
testcase_28 AC 131 ms
6,940 KB
testcase_29 AC 137 ms
6,940 KB
testcase_30 AC 134 ms
6,940 KB
testcase_31 AC 131 ms
6,940 KB
testcase_32 AC 130 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  //人を並べるための配列
  vector<pair<int,string>> P;
  //使用可能にしたかどうかを管理する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;
      P.push_back({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)P.size() > N) {
      sort(P.begin(),P.end());
      set<pair<int,string>> S;
      int j=0;
      while((int)P.size() > N) {
        if(mp[P[j].second] == true && P[j].first <= 4000) {
          P.push_back({P[j].first + 5000, P[j].second});
          P.erase(P.begin()+j);
        }
        else {
          S.insert({P[j].first%5000,P[j].second});
          P.erase(P.begin()+j);
        }
        sort(P.begin(),P.end());
      }
      for(auto j : S) cout << j.second << endl;
    }
  }
}
0