結果

問題 No.2804 Fixer And Ratism
ユーザー cho435
提出日時 2024-07-12 23:01:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,517 bytes
コンパイル時間 5,054 ms
コンパイル使用メモリ 268,508 KB
最終ジャッジ日時 2025-02-22 05:08:53
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} io_setup;
using mint = atcoder::modint1000000007;
int main(){
int nw,q;
cin>>nw>>q;
set<pair<int,string>> st,ust;
map<string,int> mp;
vector<string> ans;
rep(lp,0,q){
int t;
cin>>t;
if(t==1){
string s;
int r;
cin>>s>>r;
cin.ignore();
mp[s]=r;
st.insert({r,s});
if(nw>0) nw--;
else{
auto itr=st.begin();
assert(itr!=st.end());
ans.push_back(itr->second);
st.erase(itr);
}
}else if(t==2){
int x;
cin>>x;
cin.ignore();
set<pair<int,string>> rt;
rep(llp,0,x){
if(nw>0) nw--;
else{
auto itr=st.begin();
if(itr==st.end()){
auto uitr=ust.begin();
assert(uitr!=ust.end());
rt.insert(*uitr);
ust.erase(uitr);
}else{
rt.insert(*itr);
st.erase(itr);
}
}
}
for(auto[r,s]:rt) ans.push_back(s);
}else if(t==3){
string s;
int x;
cin>>s>>x;
cin.ignore();
if(st.count({mp[s],s})){
st.erase({mp[s],s});
ust.insert({mp[s],s});
}
assert(ust.count({mp[s],s}));
nw+=x;
}
}
for(auto s:ans) cout<<s<<"\n";
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0