Advertisement
Josif_tepe

Untitled

May 12th, 2024
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.    int k, n;
  6.    cin >> k >> n;
  7.  
  8.     int a[n], b[n];
  9.  
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> a[i];
  12.     }
  13.     for(int i = 0; i < n; i++) {
  14.         cin >> b[i];
  15.     }
  16.  
  17.     vector<int> cnt1(101, 0), cnt2(101, 0);
  18.     for(int i = 0; i < n; i++) {
  19.         cnt1[a[i]]++;
  20.         cnt2[b[i]]++;
  21.     }
  22.     long long res = 0;
  23.     for(int i = 0; i <= 100; i++) {
  24.         long long c = 0;
  25.         for(int j = 0; j <= 100; j++) {
  26.             if(i + j >= k) {
  27.                 c += cnt2[j];
  28.             }
  29.         }
  30.         res += c * cnt1[i];
  31.  
  32.     }
  33.     cout << res << endl;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement