fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7.  
  8. int arr[n+1];
  9.  
  10. for(int i=0; i<n; i++) {
  11. cin >> arr[i];
  12. }
  13.  
  14. int k1, k2;
  15. cin >> k1 >> k2;
  16.  
  17. int count = 0;
  18.  
  19. for(int j=2; j<n-2; j++) {
  20. for(int i=0; i<j-1; i++) {
  21. if(arr[i] + arr[j] > k1) {
  22. count++;
  23. }
  24. }
  25. for(int k=j+1, l=n; k<n; k++) {
  26. if(arr[k] + arr[l] > k2) {
  27. count++;
  28. }
  29. }
  30. }
  31. cout << " Count of Quadruplets: " << count;
  32. return 0;
  33. }
Success #stdin #stdout 0s 5312KB
stdin
5
1
2
3
4
5
2
3
stdout
 Count of Quadruplets: 3