Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. //#define FAST_ALLOCATOR_MEMORY 2e8
  6. //#include "optimization.h"
  7.  
  8. using namespace std;
  9.  
  10. #define ALL(x) x.begin(), x.end()
  11.  
  12. typedef long long ll;
  13. typedef unsigned long long ull;
  14. typedef long double ld;
  15. typedef pair<int,int> pii;
  16.  
  17. const int inf = (int)1e9;
  18. const ll md = (ll)1e9 + 7, inf64 = (ll)1e18;
  19.  
  20. int main() {
  21.     iostream::sync_with_stdio(0);
  22.     cin.tie(0), cout.tie(0);
  23.  
  24. #ifdef LOCAL
  25.     freopen("C:\\Users\\aytel\\CLionProjects\\common\\input.txt", "r", stdin);
  26.     freopen("C:\\Users\\aytel\\CLionProjects\\common\\output.txt", "w", stdout);
  27. #endif
  28.  
  29.     int n, m;
  30.     cin >> n >> m;
  31.  
  32.     ll sum = 0;
  33.     vector<ll> ends;
  34.     while (n--) {
  35.         ll c, t;
  36.         cin >> c >> t;
  37.         sum += c * t;
  38.         ends.push_back(sum);
  39.     }
  40.  
  41.     while (m--) {
  42.         ll t;
  43.         cin >> t;
  44.         cout << lower_bound(ends.begin(), ends.end(), t) - ends.begin() + 1 << '\n';
  45.     }
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement