結果

問題 No.2804 Fixer And Ratism
ユーザー coco0715coco0715
提出日時 2024-07-12 22:29:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,840 bytes
コンパイル時間 2,559 ms
コンパイル使用メモリ 217,576 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-12 22:29:29
合計ジャッジ時間 7,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 AC 5 ms
5,376 KB
testcase_10 RE -
testcase_11 AC 57 ms
5,376 KB
testcase_12 RE -
testcase_13 AC 13 ms
5,376 KB
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 78 ms
5,376 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 134 ms
6,944 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 133 ms
6,940 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph = vector<vector<int>>;
#define yes (cout<<"Yes"<<endl)
#define no (cout<<"No"<<endl)
#define Endl endl
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(v) sort(v.begin(),v.end());
#define rev(v) reverse(v.begin(),v.end());
#define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() );

ll INF=9223372036800000000;
int inf=200000000;
ll mod=998244353;
ll mod2=1000000007;
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={-1,0,1,-1,1,-1,0,1};
int dtt[4]={1,3,4,6};//dx,dyを4方向にする
ll two_billion=2000000000000;
int ohm=100000000;
string alpha="abcdefghijklmnopqrstuvwxyz";


int main(){
    int n,q;cin>>n>>q;
    int m=0;
    set<pair<int,string>> paken;
    set<string> dnf;
    while(q--){
        int i;cin>>i;
        if(i==1){
            string s;cin>>s;
            int r;cin>>r;
            m++;
            paken.insert({r,s});
            dnf.insert(s);
        }
        if(i==2){
            int x;cin>>x;
            n-=x;
            n=max(n,0);
        }
        if(i==3){
            string s;cin>>s;
            int x;cin>>x;
            n+=x;
            dnf.erase(s);
            //cout<<n<<endl;
        }
        if(m>n){
            int ki=m-n;
            for(auto j:paken){
                if(dnf.count(j.second)){
                    cout<<j.second<<endl;
                    m--;
                    paken.erase(j);
                    ki--;
                }
                if(ki==0)break;
            }
            if(ki)for(auto j:paken){
                if(ki==0)break;
                cout<<j.second<<endl;
                m--;
                paken.erase(j);
                ki--;
            }
        }
    }
}
0