Skip to content

Commit f1bbb2b

Browse files
committed
Added 686A - Free Ice Cream.cpp
1 parent 3154361 commit f1bbb2b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Diff for: 686A - Free Ice Cream.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
int main()
7+
{
8+
long long n,x;
9+
cin>>n>>x;
10+
char op[n];
11+
long long ic[n];
12+
for(int i=0;i<n;i++)
13+
{
14+
cin>>op[i]>>ic[i];
15+
}
16+
long long dKids=0;
17+
for(int i=0;i<n;i++)
18+
{
19+
if(op[i]=='+')
20+
{
21+
x+=ic[i];
22+
}
23+
else
24+
{
25+
if(x>=ic[i])
26+
{
27+
x-=ic[i];
28+
}
29+
else
30+
{
31+
dKids++;
32+
}
33+
}
34+
}
35+
cout<<x<<" "<<dKids<<endl;
36+
}

0 commit comments

Comments
 (0)