CF311B Cats Transport

    • 249通过
    • 586提交
  • 题目来源 CodeForces 311B
  • 评测方式 RemoteJudge
  • 标签 前缀和 斜率优化 枚举,暴力
  • 难度 省选/NOI-
  • 时空限制 2000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    题目描述

    Zxr960115 是一个大农场主。他养了m只可爱的猫子,雇佣了p个铲屎官。这里有一条又直又长的道路穿过了农场,有n个山丘坐落在道路周围,编号自左往右从1到n。山丘i与山丘i-1的距离是Di米。铲屎官们住在1号山丘。

    一天,猫子们外出玩耍。猫子i去山丘Hi游玩,在Ti时间结束他的游玩,然后在山丘Hi傻等铲屎官。铲屎官们必须把所有的猫子带上。每个铲屎官直接从H1走到Hn,中间不停下,可以认为不花费时间的把游玩结束的猫子带上。每个铲屎官的速度为一米每单位时间,并且足够强壮来带上任意数量的猫子。

    举个栗子,假装我们有两个山丘(D2=1),有一只猫子,他想去山丘2玩到时间3。然后嘞铲屎官如果在时间2或者时间3从1号山丘出发,他就能抱走猫子。如果他在时间1出发那么就不行(猫子还在玩耍)。如果铲屎官在时间2出发,猫子就不用等他(ΔT=0)。如果他在时间3出发,猫子就要等他1个单位时间。

    你的任务是安排每个铲屎官出发的时间,最小化猫子们等待的时间之和。

    感谢@Thecats 提供的翻译

    题目描述

    Zxr960115 is owner of a large farm. He feeds $ m $ cute cats and employs $ p $ feeders. There's a straight road across the farm and $ n $ hills along the road, numbered from 1 to $ n $ from left to right. The distance between hill $ i $ and $ (i-1) $ is $ d_{i} $ meters. The feeders live in hill 1.

    One day, the cats went out to play. Cat $ i $ went on a trip to hill $ h_{i} $ , finished its trip at time $ t_{i} $ , and then waited at hill $ h_{i} $ for a feeder. The feeders must take all the cats. Each feeder goes straightly from hill 1 to $ n $ without waiting at a hill and takes all the waiting cats at each hill away. Feeders walk at a speed of 1 meter per unit time and are strong enough to take as many cats as they want.

    For example, suppose we have two hills $ (d_{2}=1) $ and one cat that finished its trip at time 3 at hill 2 $ (h_{1}=2) $ . Then if the feeder leaves hill 1 at time 2 or at time 3, he can take this cat, but if he leaves hill 1 at time 1 he can't take it. If the feeder leaves hill 1 at time 2, the cat waits him for 0 time units, if the feeder leaves hill 1 at time 3, the cat waits him for 1 time units.

    Your task is to schedule the time leaving from hill 1 for each feeder so that the sum of the waiting time of all cats is minimized.

    输入输出格式

    输入格式:

    The first line of the input contains three integers $ n,m,p $ $ (2<=n<=10^{5},1<=m<=10^{5},1<=p<=100) $ .

    The second line contains $ n-1 $ positive integers $ d_{2},d_{3},...,d_{n} $ $ (1<=d_{i}&lt;10^{4}) $ .

    Each of the next $ m $ lines contains two integers $ h_{i} $ and $ t_{i} $ $ (1<=h_{i}<=n,0<=t_{i}<=10^{9}) $ .

    输出格式:

    Output an integer, the minimum sum of waiting time of all cats.

    Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

    输入输出样例

    输入样例#1: 复制
    4 6 2
    1 3 5
    1 0
    2 1
    4 9
    1 10
    2 10
    3 12
    
    输出样例#1: 复制
    3
    
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。