fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Codechef
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner sc = new Scanner(System.in) ;
  10. //taking inputes
  11. int n = sc.nextInt() ;
  12.  
  13. int k1 = sc.nextInt() ;
  14. int k2 = sc.nextInt() ;
  15.  
  16.  
  17. int arr[] = new int[n] ;
  18.  
  19. for(int i = 0 ; i < n ; i++) {
  20. arr[i] = sc.nextInt() ;
  21. }
  22.  
  23.  
  24. //O(n^4) solution complate brute force
  25.  
  26. // arr[i] + arr[j] > k1 && arr[k] + arr[l] > k2 ;
  27. int count = 0 ;
  28. for(int i = 0 ; i < n ; i++) {
  29. for(int j = i + 1 ; j < n ; j++) {
  30. for(int k = j + 1 ; k < n ; k++) {
  31. for(int l = k + 1 ; l < n ; l++) {
  32. if(arr[i] + arr[j] > k1 && arr[k] + arr[l] > k2) count++ ;
  33. }
  34. }
  35. }
  36. }
  37.  
  38. System.out.println(count);
  39.  
  40. }
  41. }
  42.  
Runtime error #stdin #stdout #stderr 0.15s 56632KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.base/java.util.Scanner.throwFor(Scanner.java:937)
	at java.base/java.util.Scanner.next(Scanner.java:1594)
	at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
	at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
	at Codechef.main(Main.java:11)