这题就是纯模拟题,我也不知道怎么错了
求求大佬帮忙看看!!
#include <bits/stdc++.h>
using namespace std;
struct enegy {
int h, e, vis;
} mapn[10010];
int N;
int x, S;
int ans = 0;
long long g = 1;
int l = 1;
int main() {
cin >> N >> S;
x = S;
for (int i = 1; i <= N; i ++) {
int q, p;
cin >> q >> p;
mapn[i].h = q;
mapn[i].e = p;
}
int t = 0;
while (x >= 1 && x <= N) {
if (mapn[x].h == 0) {
g += mapn[x].e;
if (l == 1)
l = 0;
else
l = 1;
} else if (mapn[x].h == 1) {
if (mapn[x].vis == 0 && g >= mapn[x].e) {
mapn[x].vis = 1;
ans ++;
}
}
if (l == 1)
x += g;
if (l == 0)
x -= g;
t ++;
if (t >= 3 * N)
break;
}
cout << ans;
}