# ZeroJudge - g420: PB.BAD question ### 題目連結:https://zerojudge.tw/ShowProblem?problemid=g420 ###### tags: `ZeroJudge` `模擬` ```cpp= #include <iostream> using namespace std; static const auto Initialize = [] { cin.sync_with_stdio(false); cin.tie(nullptr); return nullptr; }(); int main() { long long health; static int levels, losses[1000000], gains[1000000]; while (cin >> levels >> health) { for (int i = 0; i < levels; ++i) cin >> losses[i]; for (int i = 0; i < levels; ++i) cin >> gains[i]; for (int i = 0; i < levels; ++i) { if (health < losses[i]) { cout << i + 1 << '\n'; health = -1; break; } health += gains[i] - losses[i]; } if (health >= 0) cout << levels << '\n'; } } ```