A1320 | [COCI-2015_2016-contest6]#2 KRUMPIRKO
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Young Mr. Potato is opening two new stores where he will, you guessed it, sell potatoes. Mr. Potato gets his potatoes from N farmers. Each farmer offers exactly ai potatoes per bag for a total price of ci . Mr. Potato is going to buy all bags of potatoes from all farmers and place the bags in his two stores.
Let’s denote the average potato price in the first store with P1, and the average potato price in the second store with P
2. The average potato price in a store is equal to the ratio of the price and the total number of potatoes in the store. Taking into account logistical difficulties and the amount of potatoes in the stores, he wants the product of the average prices of potatoes in the stores to be minimal. In other words, he wants the product of P1 and P2 to be minimal.
After Mr. Potato settles on a division of bags in the stores, at least one store must have exactly L bags.
Let’s denote the average potato price in the first store with P1, and the average potato price in the second store with P
2. The average potato price in a store is equal to the ratio of the price and the total number of potatoes in the store. Taking into account logistical difficulties and the amount of potatoes in the stores, he wants the product of the average prices of potatoes in the stores to be minimal. In other words, he wants the product of P1 and P2 to be minimal.
After Mr. Potato settles on a division of bags in the stores, at least one store must have exactly L bags.
输入格式
The first line of input contains two integers N and L (2 6 N 6 100, 1 6 L < N), the number of potato bags and the number of potato bags in at least one store.
The second line of input contains N integers ai (1 6 ai 6 100), separated by space.
The third line of input contains N integers ci (1 6 ci 6 1 000 000), separated by space.
The sum of all ai will be 6 50
0.
The second line of input contains N integers ai (1 6 ai 6 100), separated by space.
The third line of input contains N integers ci (1 6 ci 6 1 000 000), separated by space.
The sum of all ai will be 6 50
0.
输出格式
The first and only line of output must contain the minimal product of P1 and P2 from the task, rounded to three decimal places.
输入输出样例
输入 #1
3 1 3 2 1 1 2 3
输出 #1
0.556
输入 #2
3 2 2 2 2 3 3 3
输出 #2
2.250
In at least 30% of examples, it will hold N 6 20.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted