daily pastebin goal
59%
SHARE
TWEET

wieza

a guest Apr 16th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. int main(void) {
  6.     std::ios_base::sync_with_stdio(false);
  7.     std::cin.tie(0);
  8.  
  9.     int height, n, m;
  10.     std::cin >> n >> m;
  11.  
  12.     std::vector<int> stairs(n);
  13.     std::cin >> stairs[0];
  14.     for (int i = 1; i < stairs.size(); ++i) {
  15.         std::cin >> stairs[i];
  16.         stairs[i] = std::max(stairs[i - 1], stairs[i]);
  17.     }
  18.  
  19.     while (m--) {
  20.         std::cin >> height;
  21.         int index = std::upper_bound(stairs.rbegin(), stairs.rend(), height, std::greater<int>()) - stairs.rbegin();
  22.         std::cout << stairs.size() - index << " ";
  23.     }
  24.     std::cout << std::endl;
  25.     return 0;
  26. }
RAW Paste Data
Top