Accepted solution

1159A- A pile of stones

Open original problem
Source code

#include <iostream>

#include<vector>

#include<string>

#include<math.h>

#include<set>

#include<map>

#include<algorithm>

/***** S. M. Sabiul Hajjaj Sabit *****/

using namespace std;

template <typename T>long long int power(T a, T b)

{

    long long int pow=1;

    for(int i=0; i<b; i++)

    {

        pow *= a;

    }

    return pow;

}

///*********Write Code From Here*********///

int main()

{

    int a;

    string s;

    int m=0;

    cin>>a;

    cin>>s;

    for(int i=0;i<s.size();i++)

    {

        if(s[i]=='+')m++;

        else m--;

        if(m<0)m=0;

    }

    cout<<m<<endl;

}
Join the discussion

Add your comment