Advertisement
dimon-torchila

Untitled

Mar 21st, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #pragma once
  2. #include "bits/stdc++.h"
  3.  
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main(){
  9. int n, m, q;
  10. cin >> n >> m >> q;
  11. map<int, unordered_set<int>> data_and_servers;
  12. vector<int> data(n, 0);
  13. unordered_set<int> c;
  14. for(int i = 1; i <= m; ++i){
  15. c.insert(i);
  16. }
  17. for(int i = 1; i <= n; ++i){
  18. data_and_servers[i] = c;
  19. }
  20. for(int i = 1; i <= q; ++i){
  21. string s;
  22. cin >> s;
  23. if(s == "RESET"){
  24. int x;
  25. cin >> x;
  26. data[x - 1]++;
  27. data_and_servers[x] = c;
  28. }
  29. else if(s == "DISABLE"){
  30. int x1, x2;
  31. cin >> x1 >> x2;
  32. if(data_and_servers[x1].find(x2) != data_and_servers[x1].end())
  33. data_and_servers[x1].erase(x2);
  34. }
  35. else if(s == "GETMAX"){
  36. int mx = INT_MIN;
  37. int mx_ind = -1;
  38. for(int i = 1; i <= n; ++i){
  39. int cnt = data[i - 1] * data_and_servers[i].size();
  40. if(mx < cnt){
  41. mx = cnt;
  42. mx_ind = i;
  43. }
  44. }
  45. cout << mx_ind << endl;
  46. }
  47. else if (s == "GETMIN"){
  48. int mx = INT_MAX;
  49. int mx_ind = -1;
  50. for(int i = 1; i <= n; ++i){
  51. int cnt = data[i - 1] * data_and_servers[i].size();
  52. if(mx > cnt){
  53. mx = cnt;
  54. mx_ind = i;
  55. }
  56. }
  57. cout << mx_ind << endl;
  58. }
  59. }
  60. }
  61.  
  62.  
  63. //3 3 12
  64. //DISABLE 1 2
  65. //DISABLE 2 1
  66. //DISABLE 3 3
  67. //GETMAX
  68. // RESET 1
  69. //RESET 2
  70. //DISABLE 1 2
  71. //DISABLE 1 3
  72. //DISABLE 2 2
  73. //GETMAX
  74. // RESET 3
  75. //GETMIN
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement