結果
| 問題 |
No.2804 Fixer And Ratism
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:54:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 2,367 bytes |
| コンパイル時間 | 4,225 ms |
| コンパイル使用メモリ | 273,652 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-12 21:54:24 |
| 合計ジャッジ時間 | 5,580 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
// #include <bits/allocator.h> // Temp fix for gcc13 global pragma
// #pragma GCC target("avx2,bmi2,popcnt,lzcnt")
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif
#ifdef LOCAL
#include "Debug.h"
#else
#define debug_endl() 42
#define debug(...) 42
#define debug2(...) 42
#define debugbin(...) 42
#endif
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
int computer, qn;
cin >> computer >> qn;
set<string> did_contribute, left;
map<string, int> rating_of;
vector<pair<int, string>> contributed;
vector<pair<int, string>> useless;
vector<string> res;
for(auto qi = 0; qi < qn; ++ qi){
int type;
cin >> type;
if(type == 1){
string name;
int r;
cin >> name >> r;
rating_of[name] = r;
useless.insert(partition_point(useless.begin(), useless.end(), [&](auto &x){ return x.first > r; }), pair{r, name});
}
else if(type == 2){
int x;
cin >> x;
computer -= x;
assert(computer >= 1);
}
else{
string name;
int x;
cin >> name >> x;
computer += x;
assert(!left.contains(name));
if(!did_contribute.contains(name)){
did_contribute.insert(name);
int r = rating_of[name];
useless.erase(partition_point(useless.begin(), useless.end(), [&](auto &x){ return x.first > r; }));
contributed.insert(partition_point(contributed.begin(), contributed.end(), [&](auto &x){ return x.first > r; }), pair{r, name});
}
}
if((int)contributed.size() + (int)useless.size() <= computer){
continue;
}
if((int)contributed.size() <= computer){
int size = min((int)useless.size(), computer - (int)contributed.size());
while((int)useless.size() > size){
res.push_back(useless.back().second);
useless.pop_back();
left.insert(res.back());
}
}
else{
while((int)contributed.size() > computer || !useless.empty()){
if(useless.empty() || (int)contributed.size() > computer && contributed.back().first < useless.back().first){
res.push_back(contributed.back().second);
contributed.pop_back();
}
else{
res.push_back(useless.back().second);
useless.pop_back();
}
left.insert(res.back());
}
}
}
ranges::copy(res, ostream_iterator<string>(cout, "\n"));
return 0;
}
/*
*/