A12499 | Stock Arbitraging
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n$ opportunities to buy shares. The $i$ -th of them allows to buy as many shares as you want, each at the price of $s_i$ bourles.
In the evening, there are $m$ opportunities to sell shares. The $i$ -th of them allows to sell as many shares as you want, each at the price of $b_i$ bourles. You can't sell more shares than you have.
It's morning now and you possess $r$ bourles and no shares.
What is the maximum number of bourles you can hold after the evening?
In the morning, there are $n$ opportunities to buy shares. The $i$ -th of them allows to buy as many shares as you want, each at the price of $s_i$ bourles.
In the evening, there are $m$ opportunities to sell shares. The $i$ -th of them allows to sell as many shares as you want, each at the price of $b_i$ bourles. You can't sell more shares than you have.
It's morning now and you possess $r$ bourles and no shares.
What is the maximum number of bourles you can hold after the evening?
输入格式
The first line of the input contains three integers $n, m, r$ ( $1 \leq n \leq 30$ , $1 \leq m \leq 30$ , $1 \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 $n$ integers $s_1, s_2, \dots, s_n$ ( $1 \leq s_i \leq 1000$ ); $s_i$ indicates the opportunity to buy shares at the price of $s_i$ bourles.
The following line contains $m$ integers $b_1, b_2, \dots, b_m$ ( $1 \leq b_i \leq 1000$ ); $b_i$ indicates the opportunity to sell shares at the price of $b_i$ bourles.
The next line contains $n$ integers $s_1, s_2, \dots, s_n$ ( $1 \leq s_i \leq 1000$ ); $s_i$ indicates the opportunity to buy shares at the price of $s_i$ bourles.
The following line contains $m$ integers $b_1, b_2, \dots, b_m$ ( $1 \leq b_i \leq 1000$ ); $b_i$ indicates the opportunity to sell shares at the price of $b_i$ bourles.
输出格式
Output a single integer — the maximum number of bourles you can hold after the evening.
输入输出样例
输入 #1
3 4 11 4 2 5 4 4 5 4
输出 #1
26
输入 #2
2 2 50 5 7 4 2
输出 #2
50
In the first example test, you have $11$ bourles in the morning. It's optimal to buy $5$ shares of a stock at the price of $2$ bourles in the morning, and then to sell all of them at the price of $5$ bourles in the evening. It's easy to verify that you'll have $26$ bourles after the evening.
In the second example test, it's optimal not to take any action.
In the second example test, it's optimal not to take any action.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted