結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2024-07-12 21:07:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,443 bytes |
| コンパイル時間 | 2,611 ms |
| コンパイル使用メモリ | 210,028 KB |
| 最終ジャッジ日時 | 2025-02-22 03:17:50 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 20 |
ソースコード
#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;
}
while(si(A)+si(B)>cn){
if(si(A)){
cout<<(*A.begin()).se<<"\n";
A.erase(A.begin());
}else{
cout<<(*B.begin()).se<<"\n";
B.erase(B.begin());
}
}
}
}
Rubikun