A936 | Rental Service--Silver
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Farmer John realizes that the income he receives from milk production is
insufficient to fund the growth of his farm, so to earn some extra money, he
launches a cow-rental service, which he calls "USACOW" (pronounced "Use-a-
cow").
Farmer John has $N$ cows ($1 \leq N \leq 100,000$), each capable of producing
some amount of milk every day. The $M$ stores near FJ's farm ($1 \leq M \leq
100,000$) each offer to buy a certain amount of milk at a certain price.
Moreover, Farmer John's $R$ ($1 \leq R \leq 100,000$) neighboring farmers are
each interested in renting a cow at a certain price.
Farmer John has to choose whether each cow should be milked or rented to a
nearby farmer. Help him find the maximum amount of money he can make per day.
insufficient to fund the growth of his farm, so to earn some extra money, he
launches a cow-rental service, which he calls "USACOW" (pronounced "Use-a-
cow").
Farmer John has $N$ cows ($1 \leq N \leq 100,000$), each capable of producing
some amount of milk every day. The $M$ stores near FJ's farm ($1 \leq M \leq
100,000$) each offer to buy a certain amount of milk at a certain price.
Moreover, Farmer John's $R$ ($1 \leq R \leq 100,000$) neighboring farmers are
each interested in renting a cow at a certain price.
Farmer John has to choose whether each cow should be milked or rented to a
nearby farmer. Help him find the maximum amount of money he can make per day.
输入格式
The first line in the input contains $N$, $M$, and $R$. The next $N$ lines
each contain an integer $c_i$ ($1 \leq c_i \leq 1,000,000$), indicating that
Farmer John's $i$th cow can produce $c_i$ gallons of milk every day. The next
$M$ lines each contain two integers $q_i$ and $p_i$ ($1 \leq q_i, p_i \leq
1,000,000$), indicating that the $i$th store is willing to buy up to $q_i$
gallons of milk for $p_i$ cents per gallon. Keep in mind that Farmer John can
sell any amount of milk between zero and $q_i$ gallons to a given store. The
next $R$ lines each contain an integer $r_i$ ($1 \leq r_i \leq 1,000,000$),
indicating that one of Farmer John's neighbors wants to rent a cow for $r_i$
cents per day.
each contain an integer $c_i$ ($1 \leq c_i \leq 1,000,000$), indicating that
Farmer John's $i$th cow can produce $c_i$ gallons of milk every day. The next
$M$ lines each contain two integers $q_i$ and $p_i$ ($1 \leq q_i, p_i \leq
1,000,000$), indicating that the $i$th store is willing to buy up to $q_i$
gallons of milk for $p_i$ cents per gallon. Keep in mind that Farmer John can
sell any amount of milk between zero and $q_i$ gallons to a given store. The
next $R$ lines each contain an integer $r_i$ ($1 \leq r_i \leq 1,000,000$),
indicating that one of Farmer John's neighbors wants to rent a cow for $r_i$
cents per day.
输出格式
The output should consist of one line containing the maximum profit Farmer
John can make per day by milking or renting out each of his cows. Note that
the output might be too large to fit into a standard 32-bit integer, so you
may need to use a larger integer type like a "long long" in C/C++.
John can make per day by milking or renting out each of his cows. Note that
the output might be too large to fit into a standard 32-bit integer, so you
may need to use a larger integer type like a "long long" in C/C++.
输入输出样例
输入 #1
5 3 4 6 2 4 7 1 10 25 2 10 15 15 250 80 100 40
输出 #1
725
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted