Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "bits/stdc++.h"
- using namespace std;
- int main(){
- int n, m, q;
- cin >> n >> m >> q;
- map<int, unordered_set<int>> data_and_servers;
- vector<int> data(n, 0);
- unordered_set<int> c;
- for(int i = 1; i <= m; ++i){
- c.insert(i);
- }
- for(int i = 1; i <= n; ++i){
- data_and_servers[i] = c;
- }
- for(int i = 1; i <= q; ++i){
- string s;
- cin >> s;
- if(s == "RESET"){
- int x;
- cin >> x;
- data[x - 1]++;
- data_and_servers[x] = c;
- }
- else if(s == "DISABLE"){
- int x1, x2;
- cin >> x1 >> x2;
- if(data_and_servers[x1].find(x2) != data_and_servers[x1].end())
- data_and_servers[x1].erase(x2);
- }
- else if(s == "GETMAX"){
- int mx = INT_MIN;
- int mx_ind = -1;
- for(int i = 1; i <= n; ++i){
- int cnt = data[i - 1] * data_and_servers[i].size();
- if(mx < cnt){
- mx = cnt;
- mx_ind = i;
- }
- }
- cout << mx_ind << endl;
- }
- else if (s == "GETMIN"){
- int mx = INT_MAX;
- int mx_ind = -1;
- for(int i = 1; i <= n; ++i){
- int cnt = data[i - 1] * data_and_servers[i].size();
- if(mx > cnt){
- mx = cnt;
- mx_ind = i;
- }
- }
- cout << mx_ind << endl;
- }
- }
- }
- //3 3 12
- //DISABLE 1 2
- //DISABLE 2 1
- //DISABLE 3 3
- //GETMAX
- // RESET 1
- //RESET 2
- //DISABLE 1 2
- //DISABLE 1 3
- //DISABLE 2 2
- //GETMAX
- // RESET 3
- //GETMIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement