Facebook
From Barbara, 5 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 191
  1. #include <iostream>
  2. using namespace std;
  3. int n, m, stos, t[100005], dub[1000006];
  4. int main ()
  5. {
  6.     ios_base::sync_with_stdio(0);
  7.     cin.tie(NULL);
  8.     cout.tie(NULL);
  9.  
  10.     cin >> n;
  11.     for (int i = 1; i <= n; i ++)
  12.         cin >> t[i];
  13.     cin >> m;
  14.     for (int i = 1; i <= m; ++ i)
  15.     {
  16.         cin >> dub[i];
  17.         int nie = 0;
  18.         for (int j = 1; j <= n; j ++)
  19.         {
  20.             nie += t[j];
  21.             if (dub[i] <= nie)
  22.             {
  23.                 cout << j << endl;
  24.                 break;
  25.             }
  26.         }
  27.     }
  28. }
  29.