Archive / 2021 / November 2021
Warzone
You are an intelligence agent in the warfront and you intercepted an enemy telegram.
The telegram reads, “The Americans have set out \(x\) number of fighter planes carrying atomic bombs. All \(y\) cities in the axis alliance are under threat!”
After near fatal consequences the troop could only obtain this critical information. The \(i\)\(th\) fighter plane is code named with an integer \(a\)\(i\) and is set out for an airstrike. The \(j\)\(th\) targeted city is coded with the integer \(b\)\(j\). Intelligence received states that bombs will only be deployed to the cities where the \(j\)\(th\) city code and ai code name of fighter plane amounts to an odd number.
All hope is on you, find the maximum number of cities under threat.
Input Format
- The first line contains the number of fighter planes(\(x\)) and cities(\(y\)).
- The second line contains \(x\) integers, \(a\)\(1\), \(a\)\(2\), …, \(a\)\(x\) — the code names of the fighter planes.
- The third line contains \(y\) integers, \(b\)\(1\), \(b\)\(2\), …, \(b\)\(y\)— the codes of cities.
Output Format
Print the maximum number of cities under threat.
Constraints
- One flight targets only one city and one city can be attacked only once.
- \(1\) \(\space\) \(\leq\) \(\space\) \(x\), \(y\) \(\space\) \(\leq\) \(\space\) \(10\)\(5\)
- \(1\) \(\space\) \(\leq\) \(\space\) \(a\), \(b\) \(\space\) \(\leq\) \(\space\) \(10\)\(9\)
Sample Input 0
5 4
19 24 6 2 21
8 4 7 20
Sample Output 0
3
Sample Input 1
5 1
1 3 5 7 9
6
Sample Output 1
1
Open on HackerRank ↗ · Markdown source · Back to the archive