Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java

import java.util.Arrays;import java.util.Scanner; public class Lambda {	public static int getC(int a[], int b[], int k) {		int c = 0;		int l = 0;		for (int ii = 0; ii < a.length; ii++) {			int ds = a[ii] - k;			int ds1 = a[ii] + k;			int h = b.length - 1; 			while (l <= h) {				if (b[l] >= ds) {					if (b[l] <= ds1) {						l = l + 1;						c++;					}					break;				} else					l++;			}			if (l == b.length - 1)				break; 		}		return c;	} 	public static void main(String[] args) {		Scanner sc = new Scanner(System.in);		int i = sc.nextInt();		int j = sc.nextInt();		int k = sc.nextInt(); 		int a[] = new int[i];		for (int l = 0; l < i; l++) {			a[l] = sc.nextInt();		}		Arrays.sort(a);		int b[] = new int[j];		for (int l = 0; l < j; l++) {			b[l] = sc.nextInt();		}		Arrays.sort(b);		System.out.println(getC(a, b, k));	}}
Source by cses.fi #
 
PREVIOUS NEXT
Tagged: #java
ADD COMMENT
Topic
Name
1+3 =