結果
問題 | No.2804 Fixer And Ratism |
ユーザー |
![]() |
提出日時 | 2024-07-03 06:47:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 2,978 bytes |
コンパイル時間 | 6,573 ms |
コンパイル使用メモリ | 337,040 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-11 23:10:39 |
合計ジャッジ時間 | 9,785 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)#define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++)#define REP(i, n) for (long long i = 1; i < (long long)(n); i++)typedef long long ll;#define updiv(N,X) (N + X - 1) / X#define l(n) n.begin(),n.end()#define YesNo(Q) Q==1?cout<<"Yes":cout<<"No"using P = pair<int, int>;using mint = modint;const int MOD = 998244353LL;const ll INF = 999999999999LL;vector<long long> fact, fact_inv, inv;/* init_nCk :二項係数のための前処理計算量:O(n)*/template <typename T>void input(vector<T> &v){rep(i,v.size()){cin>>v[i];}return;}void init_nCk(int SIZE) {fact.resize(SIZE + 5);fact_inv.resize(SIZE + 5);inv.resize(SIZE + 5);fact[0] = fact[1] = 1;fact_inv[0] = fact_inv[1] = 1;inv[1] = 1;for (int i = 2; i < SIZE + 5; i++) {fact[i] = fact[i - 1] * i % MOD;inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;}}/* nCk :MODでの二項係数を求める(前処理 int_nCk が必要)計算量:O(1)*/long long nCk(int n, int k) {assert(!(n < k));assert(!(n < 0 || k < 0));return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;}long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}ll POW(ll a,ll n){long long res = 1;while (n > 0) {if (n & 1) res = res * a;a = a * a;n >>= 1;}return res;}int main() {int n,q;cin>>n>>q;vector<string> buin;map<string,ll> buinv;int pc = n;set<ll> st1;set<ll> st2;map<ll,ll> a1;map<ll,ll> a2;//id->raterep(query,q){int t;cin>>t;if(t==1){string s;ll b;cin>>s>>b;buin.push_back(s);buinv[s] = buin.size()-1;ll a = buin.size()-1;st2.insert(b);a1[a] = b;a2[b] = a;}else if(t==2){ll a;cin>>a;pc -= a;}else{string s;ll b;cin>>s>>b;ll a = buinv[s];ll c = a1[a];//部員のレートpc += b;if(st2.count(c)){st2.erase(c);st1.insert(c);}}vector<pair<ll,string>> ans;while(pc<st1.size()+st2.size()&&(!st2.empty())){auto u = *begin(st2);ans.push_back(pair(u,buin[a2[u]]));st2.erase(u);}while(pc<st1.size()+st2.size()&&(!st1.empty())){auto u = *begin(st1);ans.push_back(pair(u,buin[a2[u]]));st1.erase(u);}sort(l(ans));rep(i,ans.size()){cout << ans[i].second << endl;}// cout<<":"<<pc<<endl;// for(auto u : st1){cout<<u<<" ";}cout<<endl;for(auto u : st2){cout<<u<<" ";}cout<<endl;}}