Advertisement
Ankit_132

A

Aug 30th, 2023
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         int n, m, q;
  13.         cin>>n>>m>>q;
  14.  
  15.         string s;
  16.         cin>>s;
  17.  
  18.         int mmax = m;
  19.         int tot = m;
  20.  
  21.         for(auto e: s)
  22.         {
  23.             m += (e == '+');
  24.             m -= (e == '-');
  25.  
  26.             mmax = max(mmax, m);
  27.             tot += (e == '+');
  28.         }
  29.  
  30.         if(mmax == n)
  31.             cout<<"YES\n";
  32.         else if(tot >= n)
  33.             cout<<"MAYBE\n";
  34.         else
  35.             cout<<"NO\n";
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement