結果

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

ソースコード

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N;cin>>N;
int Q;cin>>Q;
set<pair<int,string>> A,B;
map<string,int> MA;
int cn=N;
while(Q--){
int t;cin>>t;
if(t==1){
string X;cin>>X;
int z;cin>>z;
A.insert(mp(z,X));
MA[X]=z;
}
if(t==2){
int x;cin>>x;
cn-=x;
}
if(t==3){
string X;cin>>X;
int z;cin>>z;
if(A.count(mp(MA[X],X))){
B.insert(mp(MA[X],X));
A.erase(mp(MA[X],X));
}
cn+=z;
}
vector<pair<int,string>> Z;
while(si(A)+si(B)>cn){
if(si(A)){
Z.push_back(*A.begin());
//cout<<(*A.begin()).se<<"\n";
A.erase(A.begin());
}else{
Z.push_back(*B.begin());
//cout<<(*B.begin()).se<<"\n";
B.erase(B.begin());
}
}
sort(all(Z));
for(auto [a,b]:Z) cout<<b<<"\n";
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0