Advertisement
semsem_elazazy

Untitled

Feb 7th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6.    int n,k;
  7.    cin>>n>>k;
  8.  int arr[n];
  9.  for(int i=0 ;i<n ;i++)
  10.  {
  11.      cin>>arr[i];
  12.      
  13.  }
  14.  int c=0;
  15.  for(int i =0 ; i<n ;i++)
  16.  {
  17.      for(int j =i+1 ;j<n; j++)
  18.      {
  19.          
  20.          if ((arr[i]+arr[j]) <= k)
  21.          c++;
  22.      }
  23.  }
  24.  cout <<c;
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement