Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
- #define MX= MAX_INF
- int main()
- {
- fast();
- ll t;
- cin>>t;
- while(t--)
- {
- string s;
- cin>>s;
- ll ans=0,cnt=0;
- for(ll i=0;i<s.size();i++)
- {
- ans++;
- if(s[i]=='+')cnt++;
- else cnt--;
- if(cnt<0)
- {
- ans+=i+1;
- cnt=0;
- }
- }
- cout<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement