-
Notifications
You must be signed in to change notification settings - Fork 693
/
Solution.java
43 lines (38 loc) · 1.07 KB
/
Solution.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
//Problem: https://www.hackerrank.com/challenges/apple-and-orange
//Java 8
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int s = in.nextInt();
int t = in.nextInt();
int a = in.nextInt();
int b = in.nextInt();
int m = in.nextInt();
int n = in.nextInt();
int apples = 0;
int oranges = 0;
for(int i = 0; i < m; i++)
{
int landingSpot = in.nextInt() + a;
if(landingSpot >= s && landingSpot <= t)
{
apples++;
}
}
for(int i = 0; i < n; i++)
{
int landingSpot = in.nextInt() + b;
if(landingSpot >= s && landingSpot <= t)
{
oranges++;
}
}
System.out.println(apples);
System.out.println(oranges);
}
}