eolymp
bolt
Try our new interface for solving problems
Problems

Billy, Willy and Moscow Underground

Billy, Willy and Moscow Underground

World’s economy depression of the \textbf{2008} affected everybody in the world and harmed a lot of businesses. But Rich Scrooge McDuck’s business suffered most of all. His gold factories started yielding a loss and even went bankrupt. Moreover, the US government revealed that Scrooge was involved in illegal mortgage practices. He had no other option but to leave USA and go abroad. You know what? He chose Russia! -- \textit{Uncle Scrooge, we want to try Moscow underground, buy tickets for us!} --- said Billy and Willy, who had come on their holidays to visit their poor uncle. -- \textit{Okey, wait a moment, please} --- uncle Scrooge answered pensively. He tried to figure out how to spent the least possible money and please his nephews at the same time. Since Scrooge has never liked mathematics, he needs your help. It is known that Billy and Willy stay in Moscow for \textbf{n}days. They like underground and want to spend some of days to explore it (one trip a day). All the rest days they are going to visit Gorky Park. To prevent squabbles between Billy and Willy, Scrooge needs to give them separate tickets even if they go to underground together. At the end of each day nephews should return their tickets back to uncle. Scrooge has special relations in Moscow underground and can buy tickets for \textbf{A} passages and \textbf{B} days cheaper than they are sold to ordinary people. Certainly, he wants to buy minimum possible number of tickets, so he needs to determine which tickets to give Billy and Willy in the morning. You are hired to help McDuck solve this tricky problem! Note that the single ticket allows you to use underground no more than \textbf{A} times and the number of days between the first and the last passage should be less than \textbf{B}. \InputFile In the first line of the input there is integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{200}) and the integers \textbf{A} and \textbf{B} (\textbf{1} ≤ \textbf{A}, \textbf{B} ≤ \textbf{20}). In the second and third lines contain numbers \textbf{a_1}, \textbf{a_2}, ..., \textbf{a_n} and \textbf{b_1}, \textbf{b_2}, ,,,, \textbf{b_n} respectively (\textbf{a_i}, \textbf{b_i} ∈ \{\textbf{0}, \textbf{1}\}). Billy uses underground on the ith day if and only if \textbf{a_i = 1}. Willy uses underground on the ith day if and only if \textbf{b_i = 1}. \OutputFile Output one number --- the minimum number of tickets that Scrooge should buy for Billy and Willy. \textit{\textbf{Note}} In the last test Scrooge should give two tickets at the first day, so they stop working at the eleventh day and he should give Billy one more ticket.
Time limit 1 second
Memory limit 256 MiB
Input example #1
2 5 5
1 1
0 0
Output example #1
1
Source ACM ICPC 2012-2013, NEERC, Moscow Subregion, Moscow, Sunday, October 21, 2012