QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#3441. 银行队列

统计

Oliver 是 KTH 附近一家银行的经理,他很快就要关门了。许多人排在队列中,想要在听说银行将利率提高了 42%(从每年 0.01% 提高到每年 0.0142%)后将现金存入他们的账户。

然而,人太多了,而且只有一个柜台开放,每分钟只能服务一个人。Oliver 很贪心,他想从队列中挑选一些人,使得这些人存入的现金总额尽可能大,这样这些钱就可以在银行过夜。

不过有一个问题。有些人没有时间等到银行关门,因为他们必须赶去别的地方,所以他们必须在某个特定时间之前得到服务,否则他们就会离开。Oliver 还关闭了银行外的红外门传感器,这样就不会再有人进入了,因为大厅里已经太拥挤了。

任务

帮助 Oliver 计算在银行关门前,通过每分钟最多服务一个人,他能从排队的人那里获得的最大现金总额。

输入格式

第一行包含两个整数 $N$ ($1 \le N \le 10\,000$) 和 $T$ ($1 \le T \le 47$),分别表示队列中的人数和距离银行关门的分钟数。接下来 $N$ 行,每行包含两个整数 $c_i$ 和 $t_i$,分别表示第 $i$ 个人拥有的瑞典克朗现金金额,以及该人如果不被服务就会离开的时间(从现在开始计算的分钟数)。注意,服务一个人需要一分钟,并且你必须最晚在时间 $t_i$ 开始服务该人。你可以假设 $1 \le c_i \le 100\,000$ 且 $0 \le t_i < T$。

输出格式

输出一行,表示在银行关门前你能从排队的人那里获得的最大金额。

样例

输入 1

4 4
1000 1
2000 2
500 2
1200 0

输出 1

4200

输入 2

3 4
1000 0
2000 1
500 1

输出 2

3000

Figure 1. A queue of people waiting at a bank.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.