Associated Course(s):
Sudo Placement 2019

Given an array of penalties **P**, an array of car numbers **C**, and also the date **D**. The task is to find the total fine which will be collected on the given date. Fine is collected from odd-numbered cars on even dates and vice versa.

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. Then T test cases follow. Each test case consists of three lines of input. First line of each test case contains two integers **N** & **D**, second line contains **N** space separated car numbers **C** and third line contains **N** space separated penalties **P**.

**Output:**

For each test case,In new line print the total fine.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{5}

1000 <= C_{i} <= 9999

1 <= D <= 31

1 <= P_{i} <= 10^{3}

**Example:
Input:**

2

4 12

2375 7682 2325 2352

250 500 350 200

3 8

2222 2223 2224

200 300 400

600

300

**Explantion:**

**Testcase1: **The date is 12 (even), so we collect the fine from odd numbered cars. The odd numbered cars and the fines associated with them are as follows:

2375 -> 250

2325 -> 350

The sum of the fines is 250+350 = 600

Author: arun03

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

CodeBuddy | 164 |

hardikJain5 | 142 |

Akkki111 | 141 |

__forgivingyou | 120 |

saurabhgrade1 | 108 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1103 |

mazumderrohit8 | 1095 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4572 |

Quandray | 4444 |

Login to report an issue on this page.