版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/polanwind/article/details/87345017
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int n, x;
long long tot, ans;
int main() {
scanf("%d %d", &n, &x);
tot = x;
for (int i = 1;i <= n;++i) {
string s;
int a;
cin >> s >> a;
if (s[0] == '+') {
tot += a;
}
else {
if (tot >= a) {
tot -= a;
}
else {
ans++;
}
}
}
printf("%lld %lld\n", tot, ans);
return 0;
}