|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const fs = require('fs'); |
| 4 | + |
| 5 | +process.stdin.resume(); |
| 6 | +process.stdin.setEncoding('utf-8'); |
| 7 | + |
| 8 | +let inputString = ''; |
| 9 | +let currentLine = 0; |
| 10 | + |
| 11 | +process.stdin.on('data', inputStdin => { |
| 12 | + inputString += inputStdin; |
| 13 | +}); |
| 14 | + |
| 15 | +process.stdin.on('end', _ => { |
| 16 | + inputString = inputString.replace(/\s*$/, '') |
| 17 | + .split('\n') |
| 18 | + .map(str => str.replace(/\s*$/, '')); |
| 19 | + |
| 20 | + main(); |
| 21 | +}); |
| 22 | + |
| 23 | +function readLine() { |
| 24 | + return inputString[currentLine++]; |
| 25 | +} |
| 26 | + |
| 27 | +// Complete the twoArrays function below. |
| 28 | +function twoArrays(k, A, B) { |
| 29 | + A = A.sort((x,y)=>x-y); |
| 30 | + B = B.sort((x,y)=>y-x); |
| 31 | + let l = A.length; |
| 32 | + while(l--){ |
| 33 | + if(A[l]+B[l]<k){ |
| 34 | + return "NO"; |
| 35 | + } |
| 36 | + } |
| 37 | + return "YES"; |
| 38 | +} |
| 39 | + |
| 40 | +function main() { |
| 41 | + const ws = fs.createWriteStream(process.env.OUTPUT_PATH); |
| 42 | + |
| 43 | + const q = parseInt(readLine(), 10); |
| 44 | + |
| 45 | + for (let qItr = 0; qItr < q; qItr++) { |
| 46 | + const nk = readLine().split(' '); |
| 47 | + |
| 48 | + const n = parseInt(nk[0], 10); |
| 49 | + |
| 50 | + const k = parseInt(nk[1], 10); |
| 51 | + |
| 52 | + const A = readLine().split(' ').map(ATemp => parseInt(ATemp, 10)); |
| 53 | + |
| 54 | + const B = readLine().split(' ').map(BTemp => parseInt(BTemp, 10)); |
| 55 | + |
| 56 | + let result = twoArrays(k, A, B); |
| 57 | + |
| 58 | + ws.write(result + "\n"); |
| 59 | + } |
| 60 | + |
| 61 | + ws.end(); |
| 62 | +} |
0 commit comments