Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- signed main() {
- int n, q;
- cin >> n >> q;
- vector<int> hp(n);
- for (int &nr : hp) {
- cin >> nr;
- }
- for (int currPos = 0; q--;) {
- int damage;
- cin >> damage;
- while (damage >= hp[currPos] && currPos < n) {
- damage -= hp[currPos];
- currPos++;
- }
- int ans = n - currPos;
- cout << (ans ? ans : n) << endl;
- currPos %= n;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement