結果
| 問題 | No.2804 Fixer And Ratism |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 22:00:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 2,000 ms |
| コード長 | 1,170 bytes |
| コンパイル時間 | 3,846 ms |
| コンパイル使用メモリ | 224,552 KB |
| 最終ジャッジ日時 | 2025-02-22 04:01:04 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#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';
}
}