Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cmath>
- #include <cstring>
- #include <iomanip>
- #include <iostream>
- #include <limits>
- #include <map>
- #include <queue>
- #include <set>
- #include <stack>
- #include <string>
- #include <tuple>
- #include <unordered_map>
- #include <unordered_set>
- #include <vector>
- using namespace std;
- typedef long long ll;
- const double eps = 1e-10;
- const int mod = 1000000007;
- int main() {
- ll n, m, q; cin >> n >> m >> q;
- vector<ll> resets(n);
- vector<unordered_set<int>> broken_servers(n);
- set<pair<ll, int>> answ;
- for (int i = 0; i < n; ++i)
- answ.insert(make_pair(0, i));
- for (int i = 0; i < q; ++i) {
- string query; cin >> query;
- if (query == "RESET") {
- int d; cin >> d; --d;
- answ.erase(make_pair(resets[d] * (m - broken_servers[d].size()), d));
- broken_servers[d].clear();
- ++resets[d];
- answ.insert(make_pair(resets[d] * m, d));
- } else if (query == "DISABLE") {
- int d, s; cin >> d >> s; --d; --s;
- if (!broken_servers[d].contains(s)) {
- answ.erase(make_pair(resets[d] * (m - broken_servers[d].size()), d));
- broken_servers[d].insert(s);
- answ.insert(make_pair(resets[d] * (m - broken_servers[d].size()), d));
- }
- } else if (query == "GETMIN") {
- cout << answ.begin()->second + 1 << "\n";
- } else if (query == "GETMAX") {
- auto it = answ.lower_bound(make_pair(answ.rbegin()->first, 0));
- cout << it->second + 1 << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement