Advertisement
Dmaxiya

分布式队列 参考代码

Mar 8th, 2025
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long LL;
  5. const int maxn = 100 + 100;
  6. int n, x;
  7. string cmd;
  8. int cnt[maxn];
  9.  
  10. int main() {
  11. #ifdef ExRoc
  12.     freopen("test.txt", "r", stdin);
  13. #endif // ExRoc
  14.     ios::sync_with_stdio(false);
  15.  
  16.     cin >> n;
  17.     while (cin >> cmd) {
  18.         if (cmd[0] == 'a') {
  19.             cin >> x;
  20.             ++cnt[0];
  21.         }
  22.         if (cmd[0] == 's') {
  23.             cin >> x;
  24.             cnt[x] = min(cnt[x] + 1, cnt[0]);
  25.         }
  26.         if (cmd[0] == 'q') {
  27.             int ans = cnt[0];
  28.             for (int i = 0; i < n; ++i) {
  29.                 ans = min(ans, cnt[i]);
  30.             }
  31.             cout << ans << endl;
  32.         }
  33.     }
  34.  
  35.     return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement