لینکهای مفید برای شرکت در مسابقه:
در طول مسابقه، میتوانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.
Roosters of the sky (as discussed previously) moved to help the students. But nothing went out as expected. Since roosters can’t fly, they had to move on land. They wanted to come to SBU, but most of the highways were on “Tarhe zowj o fard”. So they had to come from Sadr highway to avoid cameras. But unfortunately, they got stuck in traffic and got there late. The evil professor was successful. Most of the students failed.
Roosters didn’t want to come back home ashamed. They planned to attack university in the middle of the night! This way, they could change the grades, so that most of the students could pass the exam and hens of the sky were relieved.
Now, it’s midnight and they are in the SBU and logged into evil professor’s “Golestan” account. If they add more than K units to the grades in total, evil professor will understand and changes the grades. Each student will become happy hi units if he/she was failed and then passes the course. Help the roosters change the grades, so that increased happiness between students is maximum, and evil professor doesn’t understand. Student with at least 10 grades is passed.
First line of the input contains an integer — number of tests to answer.
First line of each test contains two integer — the number of students.
Second line of each test contains integers — the grades of students.
Second line of each test contains integers — increase of happiness in each failed student if he/she suddenly passes.
For each test, print a single integer in one line — Maximum amount of increase in the happiness.