In this problem [A : Free Ice Cream](http://codeforces.me/contest/686/problem/A), upon taking the string inputs, why is the null string read in the first iteration? Below shows my accepted soln. (the soln I rather proposed in my mind was to run the loop from i=0 to i<n which throws errors.↵
↵
↵
~~~~~↵
#include<bits/stdc++.h>↵
using namespace std;↵
↵
int main(){↵
long long int n,x;↵
cin>>n>>x;↵
long long int cnt=0, ans=x;↵
for(int i=0;i<=n;i++){↵
string s;↵
getline(cin,s);↵
if(i==0) continue;↵
auto temp = s.substr(2);↵
long long int num = stoi(temp);↵
if(s[0]=='+'){↵
ans+=num;↵
}↵
else{↵
if(ans>=num){↵
ans-=num;↵
}↵
else{↵
cnt++;↵
}↵
}↵
}↵
cout<<ans<<" "<<cnt<<endl;↵
}↵
~~~~~↵
↵
↵
↵
~~~~~↵
#include<bits/stdc++.h>↵
using namespace std;↵
↵
int main(){↵
long long int n,x;↵
cin>>n>>x;↵
long long int cnt=0, ans=x;↵
for(int i=0;i<=n;i++){↵
string s;↵
getline(cin,s);↵
if(i==0) continue;↵
auto temp = s.substr(2);↵
long long int num = stoi(temp);↵
if(s[0]=='+'){↵
ans+=num;↵
}↵
else{↵
if(ans>=num){↵
ans-=num;↵
}↵
else{↵
cnt++;↵
}↵
}↵
}↵
cout<<ans<<" "<<cnt<<endl;↵
}↵
~~~~~↵
↵