-
Notifications
You must be signed in to change notification settings - Fork 0
/
Apple_Orange.java
49 lines (41 loc) · 1.37 KB
/
Apple_Orange.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Apple_Orange {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int s = in.nextInt();//houseStartPoint
int t = in.nextInt();//houseEndPoint
int a = in.nextInt();//appleTreePosition
int b = in.nextInt();//orangeTreePosition
int m = in.nextInt();//totalNoOfApples
int n = in.nextInt();//totalNoOfOranges
int[] apple = new int[m];
int appleFall = 0;
int appleFallCounter = 0;
int orangeFall = 0;
int orangeFallCounter = 0;
for(int apple_i=0; apple_i < m; apple_i++){
apple[apple_i] = in.nextInt();
appleFall = a+apple[apple_i];
if(appleFall >= s && appleFall <= t)
{
appleFallCounter++;
}
}
int[] orange = new int[n];
for(int orange_i=0; orange_i < n; orange_i++){
orange[orange_i] = in.nextInt();
orangeFall = b + orange[orange_i];
if(orangeFall <= t && orangeFall >= s)
{
orangeFallCounter++;
}
}
in.close();
System.out.println(appleFallCounter);
System.out.println(orangeFallCounter);
}
}