لینک‌های مفید برای شرکت در مسابقه:

در طول مسابقه، می‌توانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.

H – Revenge of the Roosters


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

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 tt — number of tests to answer.

1t601 \leq t \leq 60

First line of each test contains two integer N,KN, K — the number of students.

1N1001 \leq N \leq 1000K1090 \leq K \leq 10^9

Second line of each test contains NN integers a1,a2,,aNa_1, a_2, \dots, a_N — the grades of students.

0ai200 \leq a_i \leq 20

Second line of each test contains NN integers h1,h2,,hNh_1, h_2, \dots, h_N — increase of happiness in each failed student if he/she suddenly passes.

0hi1000 \leq h_i \leq 100

خروجی🔗

For each test, print a single integer in one line — Maximum amount of increase in the happiness.

مثال‌ها🔗

ورودی نمونه ۱🔗

5
4 20
0 0 0 10
1 2 3 4
4 15
0 0 0 0
4 3 2 1
4 9
0 0 0 0
100 100 100 100
3 9
1 6 5
8 6 3
2 4
8 7
2 4
Plain text

خروجی نمونه ۱🔗

5
4
0
9
4
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.