Advertisement
Josif_tepe

Untitled

Jun 10th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int k=0;
  8. int n=0;
  9. cin>>k;
  10. cin>>n;
  11.  
  12. long long br=0;
  13. long long result=0;
  14.  
  15. int niza1[n];
  16. int niza2[n];
  17.  
  18. for(int i=0; i<n; i++){
  19. cin>>niza1[i];
  20. }
  21.  
  22. for(int x=0; x<n; x++){
  23. cin>>niza2[x];
  24. }
  25. int brojac[101];
  26. int brojac1[101];
  27. for(int l=0; l<=100; l++){
  28.     brojac[l]=0;
  29.     brojac1[l]=0;
  30. }
  31.  
  32. for(int l1=0; l1<n; l1++){
  33.  
  34.        int b=niza1[l1];
  35.        brojac[b]++;
  36.  
  37.        int b1=niza2[l1];
  38.        brojac1[b1]++;
  39.  
  40. }
  41.  
  42. for(int k2=0; k2<=100; k2++){
  43. if(brojac[k2]>0){
  44.     int p=k-k2;
  45.     if(p<0){
  46.         p=0;
  47.     }
  48.     br=0;
  49.     for(int l=p; l<=100; l++){
  50.     br+=brojac1[l];
  51.     }
  52.    result+=brojac[k2]*br;
  53. }
  54. }
  55.  
  56. cout<<result;
  57.     return 0;
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement