Advertisement
shek_shek

B

Oct 6th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stack>
  3. #include <math.h>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <string.h>
  7. #include <string>
  8. #include <set>
  9. #include <memory.h>
  10. #include <vector>
  11. #include <map>
  12. #include <queue>
  13. #include <iomanip>
  14. #include <ctime>
  15. #include <cassert>
  16.  
  17. #define forn(i, n) for (int i = 0; i < (n); i++)
  18. #define ll long long
  19. #define mp(a, b) make_pair(a, b)
  20.  
  21. using namespace std;
  22.  
  23. vector <ll> a;
  24. map <ll, int> v;
  25.  
  26. int main() {
  27. #ifdef _DEBUG
  28.     freopen("input.txt", "r", stdin);
  29.     freopen("output.txt", "w", stdout);
  30. #endif
  31.     int n;
  32.     cin >> n;
  33.     int temp;
  34.     cin >> temp;
  35.     a.push_back(temp);
  36.     v[a.back()] = 1;
  37.     for (int i = 1; i < n; i++) {
  38.         cin >> temp;
  39.         a.push_back(temp + a.back());
  40.         v[a.back()] = i + 1;
  41.     }
  42.     int  m;
  43.     cin >> m;
  44.     forn (i, m) {
  45.         int q;
  46.         cin >> q;
  47.         cout << v[*(lower_bound(a.begin(), a.end(), q))] << endl;;
  48.     }
  49.  
  50.  
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement