Advertisement
Josif_tepe

Untitled

Jun 10th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int k, n;
  7.     cin >> k >> n;
  8.     vector<int> a(n), b(n);
  9.     vector<int> b1(101, 0), b2(101, 0);
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> a[i];
  12.         b1[a[i]]++;
  13.     }
  14.     for(int i = 0; i < n; i++) {
  15.         cin >> b[i];
  16.         b2[b[i]]++;
  17.     }
  18.     long long answer = 0;
  19.     for(int i = 0; i <= 100; i++) {
  20.         int kolku_fali = k - i;
  21.         if(kolku_fali < 0) {
  22.             kolku_fali = 0;
  23.         }
  24.         long long br = 0;
  25.         for(int j = kolku_fali; j <= 100; j++) {
  26.             br += b2[j];
  27.         }
  28.         answer += br * b1[i];
  29.     }
  30.     cout << answer << endl;
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement