fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7. int n,m;
  8. cin >> n >> m;
  9. vector<int> a(n);
  10. unordered_map<int,int> freq;
  11. for(int i=0;i<n;i++) cin >> a[i];
  12. vector<int> ans;
  13. int ma = *max_element(a.begin(),a.end());
  14. while(m--){
  15. char c;
  16. int l,r;
  17. cin >> c >> l >> r;
  18. if(c=='-'){
  19. if(ma>=l && ma<=r) ma--;
  20. ans.push_back(ma);
  21. }
  22. else if(c=='+'){
  23. if(ma>=l && ma<=r) ma++;
  24. ans.push_back(ma);
  25. }
  26. }
  27. for(int i=0;i<ans.size();i++) cout << ans[i] << " " ;
  28. cout << '\n';
  29. }
  30.  
  31. int main(){
  32. ios::sync_with_stdio(false);
  33. cin.tie(nullptr);
  34.  
  35. int t;
  36. cin >> t;
  37. while (t--) solve();
  38.  
  39.  
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 5324KB
stdin
5
5 5
1 2 3 2 1
+ 1 3
- 2 3
+ 1 2
+ 2 4
- 6 8
5 5
1 3 3 4 5
+ 1 4
+ 2 3
- 4 5
- 3 3
- 2 6
5 5
1 1 1 1 1
+ 2 3
- 4 5
+ 1 6
- 2 5
+ 1 8
1 1
1
- 1 1
1 1
1000000000
+ 1000000000 1000000000
stdout
4 4 4 5 5 
5 5 4 4 3 
1 1 2 1 2 
0 
1000000001