Advertisement
Josif_tepe

Untitled

Mar 15th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 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.     int cnt[105];
  15.     for(int i = 0; i < 105; i++) {
  16.         cnt[i] = 0;
  17.     }
  18.     for(int i = 0; i < n; i++) {
  19.         cin >> a[i];
  20.     }
  21.     for(int j = 0; j < n; j++) {
  22.         cin >> b[j];
  23.         cnt[b[j]] += 1;
  24.     }
  25.     long long answer = 0;
  26.     for(int i = 0; i < n; i++) {
  27.         int potrebno = k - a[i];
  28.         if(potrebno < 0) {
  29.             potrebno = 0;
  30.         }
  31.         for(int j = potrebno; j <= 100; j++) {
  32.             answer += cnt[j];
  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