A11259 | Michael and Charging Stations
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Michael has just bought a new electric car for moving across city. Michael does not like to overwork, so each day he drives to only one of two his jobs.
Michael's day starts from charging his electric car for getting to the work and back. He spends $1000$ burles on charge if he goes to the first job, and $2000$ burles if he goes to the second job.
On a charging station he uses there is a loyalty program that involves bonus cards. Bonus card may have some non-negative amount of bonus burles. Each time customer is going to buy something for the price of $x$ burles, he is allowed to pay an amount of $y$ ( $0<=y<=x$ ) burles that does not exceed the bonus card balance with bonus burles. In this case he pays $x-y$ burles with cash, and the balance on the bonus card is decreased by $y$ bonus burles.
If customer pays whole price with cash (i.e., $y=0$ ) then 10% of price is returned back to the bonus card. This means that bonus card balance increases by  bonus burles. Initially the bonus card balance is equal to 0 bonus burles.
Michael has planned next $n$ days and he knows how much does the charge cost on each of those days. Help Michael determine the minimum amount of burles in cash he has to spend with optimal use of bonus card. Assume that Michael is able to cover any part of the price with cash in any day. It is not necessary to spend all bonus burles at the end of the given period.
Michael's day starts from charging his electric car for getting to the work and back. He spends $1000$ burles on charge if he goes to the first job, and $2000$ burles if he goes to the second job.
On a charging station he uses there is a loyalty program that involves bonus cards. Bonus card may have some non-negative amount of bonus burles. Each time customer is going to buy something for the price of $x$ burles, he is allowed to pay an amount of $y$ ( $0<=y<=x$ ) burles that does not exceed the bonus card balance with bonus burles. In this case he pays $x-y$ burles with cash, and the balance on the bonus card is decreased by $y$ bonus burles.
If customer pays whole price with cash (i.e., $y=0$ ) then 10% of price is returned back to the bonus card. This means that bonus card balance increases by  bonus burles. Initially the bonus card balance is equal to 0 bonus burles.
Michael has planned next $n$ days and he knows how much does the charge cost on each of those days. Help Michael determine the minimum amount of burles in cash he has to spend with optimal use of bonus card. Assume that Michael is able to cover any part of the price with cash in any day. It is not necessary to spend all bonus burles at the end of the given period.
输入格式
The first line of input contains a single integer $n$ ( $1<=n<=300000$ ), the number of days Michael has planned.
Next line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $a_{i}=1000$ or $a_{i}=2000$ ) with $a_{i}$ denoting the charging cost at the day $i$ .
Next line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $a_{i}=1000$ or $a_{i}=2000$ ) with $a_{i}$ denoting the charging cost at the day $i$ .
输出格式
Output the minimum amount of burles Michael has to spend.
输入输出样例
输入 #1
3 1000 2000 1000
输出 #1
3700
输入 #2
6 2000 2000 2000 2000 2000 1000
输出 #2
10000
In the first sample case the most optimal way for Michael is to pay for the first two days spending 3000 burles and get 300 bonus burles as return. After that he is able to pay only 700 burles for the third days, covering the rest of the price with bonus burles.
In the second sample case the most optimal way for Michael is to pay the whole price for the first five days, getting 1000 bonus burles as return and being able to use them on the last day without paying anything in cash.
In the second sample case the most optimal way for Michael is to pay the whole price for the first five days, getting 1000 bonus burles as return and being able to use them on the last day without paying anything in cash.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted