405221: GYM101848 E Balance Reset

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Balance Resettime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

You are graduating from your school. There are still some money on your student card, and you don't want to waste even one dollar.

The only way to reset your balance, is to eat lunch, at the school canteen. The canteen offers 2n kinds of meals, selling a1, a2, ..., a2n dollars respectively. Every day, the canteen randomly pick n kinds of meals that will be selling today. In other words, the other half will NOT be on "today's menu". When you recharge your student card, only multiples of 100 is acceptable.

Your balance now is p dollars.

You can always recharge your student card every day. And after the recharging, you will decide to eat at the canteen or not. If yes, you have to pick one of those n kinds of meals. The target is to make the balance on your student card become 0 in 365 days.

The dataset guarantees that this is possible.

Interaction

You will first read two space-separated integers n and p (1 ≤ n ≤ 500, 1 ≤ p ≤ 100).

The second line contains 2n space-separated integers a1, a2, ..., a2n (1 ≤ ai ≤ 100). They are the prices of the meals.

Then for every day, you will read n space-separated integers i1, i2, ..., in from the interactor, denoting which n meals are sold today. The prices are, of course, ai1, ai2, ..., ain. The interactor guarantees that its choices are completely random. There will not be strategies against you.

You will respond in the following way: output two space-separated integers c and s (0 ≤ c ≤ 100, s = 0 or ). c is the number of 100 dollars, that is 100·c dollars you are going to recharging with. s is your choice. If you decide not to eat at the canteen, s = 0.

If when the day is over, your balance is already 0. Please exit your program immediately. Exiting too early or too late will not pass the test.

ExampleInput
2 5
2 3 3 3
1 2
2 3
Output
0 1
0 2

加入题单

算法标签: