22836_CowPlumbing

2022-5-16 18:23| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-895074643600-Problem List-采集的数据-后羿采集器.html

Pro.ID

22836

Title

Cow Plumbing

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22836

AC

0

Submit

1

Ratio

0.00%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The cows want to move water from the pond to the barn, a distance of D (7 ≤ D ≤ 100,000). They have a set of P (1 ≤ P ≤ 350) pipes, each with positive integer length Li and positive integer capacity Ci (both numbers fit in 24 bits).

    The pipes can be connected in series into a run: the connected pipes have the capacity that is the least of all pipes' individual capacities. A run must reach precisely D units (i.e., the sum of the Li's for the pipes in a run must be D).

    Find the maximum amount of water that can be moved from the pond to the barn in one single run of pipe.

    输入

    * Line 1: One line with two integers: D and P

    * Lines 2..N+1: Each line contains two integers describing a pipe: Li and Ci

    输出

    Description

    The cows want to move water from the pond to the barn, a distance of D (7 ≤ D ≤ 100,000). They have a set of P (1 ≤ P ≤ 350) pipes, each with positive integer length Li and positive integer capacity Ci (both numbers fit in 24 bits).

    The pipes can be connected in series into a run: the connected pipes have the capacity that is the least of all pipes' individual capacities. A run must reach precisely D units (i.e., the sum of the Li's for the pipes in a run must be D).

    Find the maximum amount of water that can be moved from the pond to the barn in one single run of pipe.

    Input

    * Line 1: One line with two integers: D and P

    * Lines 2..N+1: Each line contains two integers describing a pipe: Li and Ci

    Output

    One line with a single integer that is the maximum possible legal flow.

    Sample Input

    7 6
    4 5
    3 6
    2 7
    1 4
    6 7
    1 5

    Sample Output

    5

    Source

    样例输入

    7 6
    4 5
    3 6
    2 7
    1 4
    6 7
    1 5

    样例输出

    5

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部