Advertisement
tuki2501

243427_a.cpp

Jan 9th, 2022
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. namespace sub_1_2 {
  7.   void solve(int n, int q) {
  8.     vector<int> a(n), b(q);
  9.     for (auto &i : a) cin >> i;
  10.     for (auto &i : b) cin >> i;
  11.     sort(a.begin(), a.end());
  12.     for (auto &i : b) {
  13.       int pos = upper_bound(a.begin(), a.end(), i) - a.begin();
  14.       cout << pos << '\n';
  15.     }
  16.   }
  17. }
  18.  
  19. namespace sub_3_4 {
  20.   void solve(int n, int q, int k) {
  21.     vector<vector<int>> a(n, vector<int>(k)), b(q, vector<int>(k));
  22.     for (auto &i : a) for (auto &j : i) cin >> j;
  23.     for (auto &i : b) for (auto &j : i) cin >> j;
  24.     for (auto &i : b) {
  25.       int cnt = 0;
  26.       for (auto &j : a) {
  27.         bool flag = false;
  28.         for (int l = 0; l < k; l++) {
  29.           if (i[l] < j[l]) {
  30.             flag = true;
  31.             break;
  32.           }
  33.         }
  34.         if (!flag) cnt++;
  35.       }
  36.       cout << cnt << '\n';
  37.     }
  38.   }
  39. }
  40.  
  41. signed main() {
  42.   cin.tie(0)->sync_with_stdio(0);
  43.   int T; cin >> T;
  44.   while (T--) {
  45.     int n, q, k;
  46.     cin >> n >> q >> k;
  47.     if (k == 1 && n <= 100000) sub_1_2::solve(n, q);
  48.     else sub_3_4::solve(n, q, k);
  49.   }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement