P2918 [USACO08NOV]买干草Buying Hay

    • 284通过
    • 646提交
  • 题目提供者 FarmerJohn2
  • 评测方式 云端评测
  • 标签 背包 贪心 USACO 2008
  • 难度 普及/提高-
  • 时空限制 1000ms / 128MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 最新讨论 显示

    推荐的相关题目 显示

    题目描述

    Farmer John is running out of supplies and needs to purchase H (1 <= H <= 50,000) pounds of hay for his cows.

    He knows N (1 <= N <= 100) hay suppliers conveniently numbered 1..N. Supplier i sells packages that contain P_i (1 <= P_i <= 5,000) pounds of hay at a cost of C_i (1 <= C_i <= 5,000) dollars. Each supplier has an unlimited number of packages available, and the packages must be bought whole.

    Help FJ by finding the minimum cost necessary to purchase at least H pounds of hay.

    约翰的干草库存已经告罄,他打算为奶牛们采购丹(1 <=H< =50000)镑干草.

    他知道N(l<=N<=100)个干草公司,现在用1到N给它们编号.第公司卖的干草包重量 为巧P_i (1 <= P_i <= 5,000) 磅,需要的开销为C_i (1 <= C_i <= 5,000) 美元.每个干草公司的货源都十分充足, 可以卖出无限多的干草包.

    帮助约翰找到最小的开销来满足需要,即采购到至少H镑干草.

    输入输出格式

    输入格式:

    * Line 1: Two space-separated integers: N and H

    * Lines 2..N+1: Line i+1 contains two space-separated integers: P_i and C_i

    输出格式:

    * Line 1: A single integer representing the minimum cost FJ needs to pay to obtain at least H pounds of hay.

    输入输出样例

    输入样例#1: 复制
    2 15 
    3 2 
    5 3 
    
    输出样例#1: 复制
    9 
    

    说明

    FJ can buy three packages from the second supplier for a total cost of 9.

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。