Created
March 4, 2017 06:36
-
-
Save torpedo87/e08bd26cddd9bd437d13f5aefb4f1d87 to your computer and use it in GitHub Desktop.
##[apple and orange](https://www.hackerrank.com/challenges/apple-and-orange)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
var s_temp = readLine().split(' '); | |
var s = parseInt(s_temp[0]); | |
var t = parseInt(s_temp[1]); | |
var a_temp = readLine().split(' '); | |
var a = parseInt(a_temp[0]); | |
var b = parseInt(a_temp[1]); | |
var m_temp = readLine().split(' '); | |
var m = parseInt(m_temp[0]); | |
var n = parseInt(m_temp[1]); | |
apple = readLine().split(' '); | |
apple = apple.map(Number); | |
orange = readLine().split(' '); | |
orange = orange.map(Number); | |
var appleNum=0; | |
for(var i=0; i<m; i++){ | |
if(a+apple[i]>=s && a+apple[i]<=t){ | |
appleNum+=1; | |
} | |
} | |
var orangeNum=0; | |
for(var i=0; i<n; i++){ | |
if(b+orange[i]>=s && b+orange[i]<=t){ | |
orangeNum+=1; | |
} | |
} | |
console.log(appleNum); | |
console.log(orangeNum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment