結果

問題 No.2804 Fixer And Ratism
ユーザー Carpenters-Cat
提出日時 2024-07-12 22:03:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,067 bytes
コンパイル時間 3,171 ms
コンパイル使用メモリ 219,656 KB
最終ジャッジ日時 2025-02-22 04:06:58
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using P = pair<int, string>;
int main () {
int N, Q;
cin >> N >> Q;
priority_queue<P, std::vector<P>, greater<P>> pque1, pque2 ;
map<string, int> mpp, rte;
int can_use = N;
int num_b = 0;
while (Q--) {
int t;
cin >> t;
if (t == 1) {
string s; int r;
cin >> s >> r;
pque1.emplace(r, s);
num_b ++;
mpp[s] = 1;
rte[s] = r;
} else if (t == 2) {
int x;
cin >> x;
can_use -= x;
} else {
int x; string s;
cin >> s >> x;
if (mpp[s] != 2) {
mpp[s] = 2;
pque2.emplace(rte[s], s);
}
can_use += x;
}
vector<P> ret;
while (!pque1.empty() && num_b > can_use) {
auto [r, s] = pque1.top();
pque1.pop();
if (mpp[s] == 1) {
num_b --;
ret.emplace_back(r, s);
mpp[s] = 0;
}
}
while (!pque2.empty() && num_b > can_use) {
auto [r, s] = pque2.top();
pque2.pop();
if (mpp[s] == 2) {
num_b --;
ret.emplace_back(r, s);
mpp[s] = 0;
}
}
sort(ret.begin(), ret.end());
for (auto& [r1, s2] : ret) cout << s2 << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0