Posted by : Ezzeldin Adel Monday, June 27, 2016

Codeforces 686A| Free Ice Cream



Question:
http://codeforces.com/problemset/problem/686/A


Solution: #include

#include
using
namespace std; int main() { long long x, n ; cin >> n >> x; int dis =0 ; for ( int i = 0 ; i< n ; i++) // handle n operations { char c; int xx; cin >> c >> xx; if ( c == '+') x+=xx; // add more ice cream to ours YAY else { // - give icecream :( if ( xx<=x) x-=xx; // if we have enough to give em lets just do it else // turn em down dis++; } } cout << x << " " << dis; return 0; } // ez@macacm.org -- 12:05PM 27-06-2016 // Ezzeldin Adel Tahoun || McMaster University


Video Explanation: 





If you want us to solve any certain question please leave it down in the comments or send it to us on facebook

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Discover

Top 5 Posts

- Copyright © McMaster ACM Chapter | Protected by CloudFlare