Subscribe Us

Responsive Advertisement

Advertisement

686A codeforces solution in cpp

 


686A codeforces solution in cpp

by ujjal roy 


#include<bits/stdc++.h>

using namespace std;

main()

{


    long long int n,x,i,d,sum;

    cin>>n>>x;

     int c=0;

    while(n--)

    {


       char ce;

       cin>>ce>>d;

       if(ce=='+')x+=d;

       else

       {

           if(x>=d)x-=d;

           else c++;

       }


    }

 cout<<x<<" "<<c<<endl;


    return 0;

}

 

Post a Comment

0 Comments