codeforces1106e(优先队列+dp)

传送门:http://codeforces.com/problemset/problem/1106/E

E. Lunar New Year and Red Envelopes

time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Lunar New Year is approaching, and Bob is going to receive some red envelopes with countless money! But collecting money from red envelopes is a time-consuming process itself.

Let's describe this problem in a mathematical way. Consider a timeline from time 11 to nn. The ii-th red envelope will be available from time sisi to titi, inclusive, and contain wiwi coins. If Bob chooses to collect the coins in the ii-th red envelope, he can do it only in an integer point of time between sisi and titi, inclusive, and he can't collect any more envelopes until time didi (inclusive) after that. Here si≤ti≤disi≤ti≤di holds.

Bob is a greedy man, he collects coins greedily — whenever he can collect coins at some integer time xx, he collects the available red envelope with the maximum number of coins. If there are multiple envelopes with the same maximum number of coins, Bob would choose the one whose parameter dd is the largest. If there are still multiple choices, Bob will choose one from them randomly.

However, Alice — his daughter — doesn't want her father to get too many coins. She could disturb Bob

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值