CF1612E Messages

题目描述

Monocarp 是 $n$ 个学生的导师。现在有很多条消息,Monocarp 希望第 $i$ 个学生阅读编号为 $m_i$ 的消息。他需要把一些消息置顶,因为学生只会阅读置顶的消息。 学生 $i$ 有一个属性 $k_i$。如果你置顶了 $t$ 条消息,若 $t\le k_i$,该学生会阅读所有置顶消息;否则,该学生会从置顶的 $t$ 条消息中随机选 $k_i$ 条阅读。 你需要求出在使得第 $i$ 名学生阅读到第 $m_i$ 条消息的 $i$ 的数量的期望值最大时,你应该置顶哪些消息。如果有多个答案,输出任意一种。

输入格式

第一行一个整数 $n\ (1\le n\le 2\times 10^5)$。 接下来 $n$ 行,第 $i$ 行有两个整数 $m_i,k_i\ (1\le m_i\le 2\times 10^5,1\le k_i\le 20)$。

输出格式

第一行一个整数 $t$,表示你置顶的消息条数。 第二行包含 $t$ 个整数 $c_1,c_2,\dots,c_t$,表示你置顶的消息编号。

说明/提示

Let's consider the examples from the statement. 1. In the first example, Monocarp pins the messages $ 5 $ and $ 10 $ . - if the first student reads the message $ 5 $ , the second student reads the messages $ 5 $ and $ 10 $ , and the third student reads the messages $ 5 $ and $ 10 $ , the number of students which have read their respective messages will be $ 2 $ ; - if the first student reads the message $ 10 $ , the second student reads the messages $ 5 $ and $ 10 $ , and the third student reads the messages $ 5 $ and $ 10 $ , the number of students which have read their respective messages will be $ 3 $ . So, the expected number of students which will read their respective messages is $ \frac{5}{2} $ . 2. In the second example, Monocarp pins the message $ 10 $ . - if the first student reads the message $ 10 $ , the second student reads the message $ 10 $ , and the third student reads the message $ 10 $ , the number of students which have read their respective messages will be $ 2 $ . So, the expected number of students which will read their respective messages is $ 2 $ . If Monocarp had pinned both messages $ 5 $ and $ 10 $ , the expected number of students which read their respective messages would have been $ 2 $ as well. 3. In the third example, the expected number of students which will read their respective messages is $ \frac{8}{3} $ . 4. In the fourth example, the expected number of students which will read their respective messages is $ 2 $ .