2017-03-05 00:26:42 -06:00
|
|
|
// Author: Rodney Shaghoulian
|
2018-07-27 16:45:56 -07:00
|
|
|
// Github: github.com/RodneyShag
|
|
|
|
|
// HackerRank: hackerrank.com/RodneyShag
|
2017-03-05 00:26:42 -06:00
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
2017-04-05 18:42:35 -05:00
|
|
|
// Time Complexity: O(m + n)
|
2017-03-05 00:26:42 -06:00
|
|
|
// Space Complexity: O(1)
|
|
|
|
|
public class Solution {
|
2017-09-11 09:32:17 -07:00
|
|
|
public static void main(String[] args) {
|
2017-04-05 18:42:35 -05:00
|
|
|
/* Save input */
|
2017-03-05 00:26:42 -06:00
|
|
|
Scanner scan = new Scanner(System.in);
|
|
|
|
|
int s = scan.nextInt();
|
|
|
|
|
int t = scan.nextInt();
|
|
|
|
|
int a = scan.nextInt();
|
|
|
|
|
int b = scan.nextInt();
|
|
|
|
|
int m = scan.nextInt();
|
|
|
|
|
int n = scan.nextInt();
|
|
|
|
|
|
|
|
|
|
/* Calculate # of apples that fall on house */
|
|
|
|
|
int applesOnHouse = 0;
|
|
|
|
|
for (int i = 0; i < m; i++) {
|
|
|
|
|
int applePosition = a + scan.nextInt();
|
|
|
|
|
if (applePosition >= s && applePosition <= t) {
|
|
|
|
|
applesOnHouse++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println(applesOnHouse);
|
|
|
|
|
|
|
|
|
|
/* Calculate # of oranges that fall on house */
|
|
|
|
|
int orangesOnHouse = 0;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
int orangePosition = b + scan.nextInt();
|
|
|
|
|
if (orangePosition >= s && orangePosition <= t) {
|
|
|
|
|
orangesOnHouse++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println(orangesOnHouse);
|
|
|
|
|
|
|
|
|
|
scan.close();
|
|
|
|
|
}
|
|
|
|
|
}
|