A1297 | [COCI-2013_2014-contest3]#1 KOLINJE
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Melita has just returned from the annual pig slaughter. Don't worry, this is a regular thing in Croatia.
The best part was the abundance of food! There was everything, starting from good spicy sausages, ham, black pudding, up to teewurst, top quality bacon and čvarci, all with warm white bread and butter.
After these appetizers, it was the perfect time to whip up a deep pot full of sarma (Melita ate twentyish of them) as well as a large platter of fine roast pork, so soft that it almost melts in your mouth. They watered all of this down with copious gulps of the best dry white wine that made them even hungrier.
Butcher Bajs kept his award-winning ham for the very end. N people attented the annual pig slaughter, labeled with numbers from 1 to N. These people already ate a lot of meat: the k th person ate A[k]
kilograms of meat so far. Bajs will distribute his ham to the people in the ratio B[1] : B[2] : … : B[N], exactly in that order, but he doesn't know the total amount (number of kilos) of ham which he will be distributing yet.
At the end of the slaughter, the Man of the Year will be declared. A ranking list is made according to the total kilos of meat eaten. Bajs impacts directly on this list by choosing the amount of ham to distribute. Although Bajs has been offered bribes many times, he refused each time, saying that he was an honest man who would not hurt a fly.
Bajs cares about order, because he's a nice gentleman, and wants to have the order of people in the exact form of 1, 2, 3, ..., N, respectively from the one who ate the most kilos of meat to those who ate less, allowing ties between participants. Help Bajs select the total amount of ham that he will distribute (in the ratio mentioned before) to achieve his intention.
The best part was the abundance of food! There was everything, starting from good spicy sausages, ham, black pudding, up to teewurst, top quality bacon and čvarci, all with warm white bread and butter.
After these appetizers, it was the perfect time to whip up a deep pot full of sarma (Melita ate twentyish of them) as well as a large platter of fine roast pork, so soft that it almost melts in your mouth. They watered all of this down with copious gulps of the best dry white wine that made them even hungrier.
Butcher Bajs kept his award-winning ham for the very end. N people attented the annual pig slaughter, labeled with numbers from 1 to N. These people already ate a lot of meat: the k th person ate A[k]
kilograms of meat so far. Bajs will distribute his ham to the people in the ratio B[1] : B[2] : … : B[N], exactly in that order, but he doesn't know the total amount (number of kilos) of ham which he will be distributing yet.
At the end of the slaughter, the Man of the Year will be declared. A ranking list is made according to the total kilos of meat eaten. Bajs impacts directly on this list by choosing the amount of ham to distribute. Although Bajs has been offered bribes many times, he refused each time, saying that he was an honest man who would not hurt a fly.
Bajs cares about order, because he's a nice gentleman, and wants to have the order of people in the exact form of 1, 2, 3, ..., N, respectively from the one who ate the most kilos of meat to those who ate less, allowing ties between participants. Help Bajs select the total amount of ham that he will distribute (in the ratio mentioned before) to achieve his intention.
输入格式
The first line of input contains an integer N (2 ≤ N ≤ 1000), the number of competitors for the Man of the Year award.
Each of the following k lines contains integers A[k] i B[k], as mentioned in the text (0 ≤ A[k], B[k] ≤
106 ). At least one of the numbers B[k] will not be equal to
0.
Each of the following k lines contains integers A[k] i B[k], as mentioned in the text (0 ≤ A[k], B[k] ≤
106 ). At least one of the numbers B[k] will not be equal to
0.
输出格式
The first and only line of output must contain -1 if the required order cannot be achieved. Otherwise,
output the required amount of ham in kilos, a real number (rounded up to 12 decimal places) between 0 and 107 (inclusive). If there are multiple possible solutions, output any.
output the required amount of ham in kilos, a real number (rounded up to 12 decimal places) between 0 and 107 (inclusive). If there are multiple possible solutions, output any.
输入输出样例
输入 #1
3 7 1 3 2 10 0
输出 #1
10.5
输入 #2
3 2 1 4 0 0 3
输出 #2
-1
输入 #3
5 15 4 6 7 12 5 9 6 1 7
输出 #3
87
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted