欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1150A.Stock Arbitraging
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 opportunities to buy shares. The -th of them allows to buy as many shares as you want, each at the price of bourles.
In the evening, there are opportunities to sell shares. The -th of them allows to sell as many shares as you want, each at the price of bourles. You can't sell more shares than you have.
It's morning now and you possess 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 (, , ) — 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 integers (); indicates the opportunity to buy shares at the price of bourles.
The following line contains integers (); indicates the opportunity to sell shares at the price of 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 bourles in the morning. It's optimal to buy shares of a stock at the price of bourles in the morning, and then to sell all of them at the price of bourles in the evening. It's easy to verify that you'll have 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
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |