Advertisement
Josif_tepe

Untitled

Mar 15th, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <map>
  6. using namespace std;
  7. typedef long long ll;
  8.  
  9. int main()
  10. {
  11.     int k, n;
  12.     cin >> k >> n;
  13.     int a[n], b[n];
  14.     long long cnt_a[105], cnt_b[105];
  15.     for(int i = 0; i < 105; i++) {
  16.         cnt_a[i] = 0;
  17.         cnt_b[i] = 0;
  18.     }
  19.     for(int i = 0; i < n; i++) {
  20.         cin >> a[i];
  21.         cnt_a[a[i]] += 1;
  22.     }
  23.     for(int j = 0; j < n; j++) {
  24.         cin >> b[j];
  25.         cnt_b[b[j]] += 1;
  26.     }
  27.     long long answer = 0;
  28.     for(int i = 0; i <= 100; i++) {
  29.         for(int j = 0; j <= 100; j++) {
  30.             if(i + j >= k and cnt_a[i] > 0 and cnt_b[j] > 0) {
  31.                 answer += cnt_a[i] * cnt_b[j];
  32.             }
  33.         }
  34.     }
  35.     cout << answer << endl;
  36.     return 0;
  37. }
  38.  
  39. /*
  40.  
  41.  a[i] + b[j] >= k
  42.  k - a[i]
  43.  
  44.  **/
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement