-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathE0011.cpp
More file actions
40 lines (36 loc) · 873 Bytes
/
E0011.cpp
File metadata and controls
40 lines (36 loc) · 873 Bytes
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
/*
Problem Statement: https://www.hackerrank.com/challenges/apple-and-orange/problem
*/
#include <iostream>
#include <vector>
using namespace std;
void countApplesAndOranges(int s, int t, int a, int b, vector<int> apples, vector<int> oranges) {
int appleCount,orangeCount;
appleCount = orangeCount = 0;
for(int i=0 ; i<apples.size() ; i++)
if((a + apples[i] >= s) && (a + apples[i] <= t))
appleCount++;
for(int i=0 ; i<oranges.size() ; i++)
if((b + oranges[i] >= s) && (b + oranges[i] <= t))
orangeCount++;
cout<<appleCount<<endl;
cout<<orangeCount<<endl;
}
int main()
{
int s,t,a,b,m,n,num;
vector<int> apples,oranges;
cin>>s>>t;
cin>>a>>b;
cin>>m>>n;
for(int i=0 ; i<m ; i++){
cin>>num;
apples.push_back(num);
}
for(int i=0 ; i<n ; i++){
cin>>num;
oranges.push_back(num);
}
countApplesAndOranges(s,t,a,b,apples,oranges);
return 0;
}