Advertisement
STANAANDREY

hackathon: "yanko war" de 70

Jan 24th, 2022
814
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. signed main() {
  6.     int n, q;
  7.     cin >> n >> q;
  8.     vector<int> hp(n);
  9.     for (int &nr : hp) {
  10.         cin >> nr;
  11.     }
  12.  
  13.     for (int currPos = 0; q--;) {
  14.         int damage;
  15.         cin >> damage;
  16.  
  17.         while (damage >= hp[currPos] && currPos < n) {
  18.             damage -= hp[currPos];
  19.             currPos++;
  20.         }
  21.  
  22.         int ans = n - currPos;
  23.         cout << (ans ? ans : n) << endl;
  24.  
  25.         currPos %= n;
  26.     }
  27.     return 0;
  28. }
  29.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement