結果
問題 |
No.2804 Fixer And Ratism
|
ユーザー |
![]() |
提出日時 | 2024-07-12 21:12:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 243 ms / 2,000 ms |
コード長 | 1,086 bytes |
コンパイル時間 | 5,315 ms |
コンパイル使用メモリ | 272,664 KB |
最終ジャッジ日時 | 2025-02-22 03:21:08 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 int main(){ int N,Q; cin>>N>>Q; vector<vector<pair<int,string>>> P(2); vector<string> ans; rep(i,Q){ int t; cin>>t; if(t==1){ string S; int R; cin>>S>>R; P[0].emplace_back(R,S); sort(P[0].rbegin(),P[0].rend()); } if(t==2){ int x; cin>>x; N -= x; } if(t==3){ int x; string s; cin>>s>>x; N += x; rep(j,P[0].size()){ if(P[0][j].second == s){ P[1].push_back(P[0][j]); P[0].erase(P[0].begin()+j); break; } } sort(P[1].rbegin(),P[1].rend()); } vector<pair<int,string>> tt; while(P[0].size()+P[1].size()>N){ if(P[0].size()>0){ tt.push_back(P[0].back()); P[0].pop_back(); } else{ tt.push_back(P[1].back()); P[1].pop_back(); } } sort(tt.begin(),tt.end()); rep(j,tt.size())cout<<tt[j].second<<endl; } return 0; }