CF1150A.Stock Arbitraging

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Stock Arbitraging

Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!

In the morning, there are nn opportunities to buy shares. The ii-th of them allows to buy as many shares as you want, each at the price of sis_i bourles.

In the evening, there are mm opportunities to sell shares. The ii-th of them allows to sell as many shares as you want, each at the price of bib_i bourles. You can't sell more shares than you have.

It's morning now and you possess rr bourles and no shares.

What is the maximum number of bourles you can hold after the evening?

Input

The first line of the input contains three integers n,m,rn, m, r (1n301 \leq n \leq 30, 1m301 \leq m \leq 30, 1r10001 \leq r \leq 1000) — the number of ways to buy the shares on the market, the number of ways to sell the shares on the market, and the number of bourles you hold now.

The next line contains nn integers s1,s2,,sns_1, s_2, \dots, s_n (1si10001 \leq s_i \leq 1000); sis_i indicates the opportunity to buy shares at the price of sis_i bourles.

The following line contains mm integers b1,b2,,bmb_1, b_2, \dots, b_m (1bi10001 \leq b_i \leq 1000); bib_i indicates the opportunity to sell shares at the price of bib_i bourles.

Output

Output a single integer — the maximum number of bourles you can hold after the evening.

Note

In the first example test, you have 1111 bourles in the morning. It's optimal to buy 55 shares of a stock at the price of 22 bourles in the morning, and then to sell all of them at the price of 55 bourles in the evening. It's easy to verify that you'll have 2626 bourles after the evening.

In the second example test, it's optimal not to take any action.

Samples

3 4 11
4 2 5
4 4 5 4
26
2 2 50
5 7
4 2
50

在线编程 IDE

建议全屏模式获得最佳体验