Published
Linked with GitHub
Like
Bookmark
Subscribe
# 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'; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in via Google
New to HackMD?
Sign up