-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppleOrange.cpp
52 lines (48 loc) · 1.15 KB
/
AppleOrange.cpp
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
50
51
52
/*
Sam's house has an apple tree and an orange tree that yield an abundance of fruit.
In the diagram below, the red region denotes his house, where is the start point, and is the endpoint.
The apple tree is to the left of his house, and the orange tree is to its right.
You can assume the trees are located on a single point, where the apple tree is at point , and the orange tree is at point .
*/
#include <bits/stdc++.h>
using namespace std;
int Apple(long ha[],long a,long s,long t,long m)
{
long count =0,d;
for(int i=0;i<m;i++)
{
d=a+ha[i];
if(d<=t && d>=s)
{
count++;
}
}
return count;
}
int Orange(long hb[],long b,long s,long t,long n )
{
long count =0,d;
for(int i=0;i<n;i++)
{
d=b+hb[i];
if(d<=t && d>=s)
{
count++;
}
}
return count;
}
int main()
{
long s,t,a,b,m,n;
cin>>s>>t>>a>>b>>m>>n;
long d;
long ha[m],hb[n];
for(int i=0;i<m;i++)
cin>>ha[i];
for(int i=0;i<n;i++)
cin>>hb[i];
cout<<Apple(ha,a,s,t,m)<<endl;
cout<<Orange(hb,b,s,t,n);
return 0;
}