#include<bits/stdc++.h> using namespace std; int a[1000+1]; int main() { long long t,n,sum,dist,m; char c; while(cin>>t>>m) { sum=0; dist=0; cin>>c; cin>>n; if(c=='+') { sum=m+n; } else if(c=='-') { sum=m-n; if(sum<0) { dist++; sum=sum+n; } } for(int i=1; i<t; i++) { cin>>c; cin>>n; if(c=='+') { sum+=n; } else if(c=='-') { sum-=n; if(sum<0) { dist++; sum=sum+n; } } } cout<<sum<<" "<<dist<<endl; } return 0; }
Saturday, July 23, 2016
686A - Free Ice Cream
Labels:
Codeforces
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thank you for commenting. Please wait for response :)