309018: CF1612E. Messages
Memory Limit:512 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Messages
题意翻译
Monocarp 是 $n$ 个学生的导师。现在有很多条消息,Monocarp 希望第 $i$ 个学生阅读编号为 $m_i$ 的消息。他需要把一些消息置顶,因为学生只会阅读置顶的消息。 学生 $i$ 有一个属性 $k_i$。如果你置顶了 $t$ 条消息,若 $t\le k_i$,该学生会阅读所有置顶消息;否则,该学生会从置顶的 $t$ 条消息中随机选 $k_i$ 条阅读。 你需要求出在使得第 $i$ 名学生阅读到第 $k_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$,表示你置顶的消息编号。题目描述
Monocarp is a tutor of a group of $ n $ students. He communicates with them using a conference in a popular messenger. Today was a busy day for Monocarp — he was asked to forward a lot of posts and announcements to his group, that's why he had to write a very large number of messages in the conference. Monocarp knows the students in the group he is tutoring quite well, so he understands which message should each student read: Monocarp wants the student $ i $ to read the message $ m_i $ . Of course, no one's going to read all the messages in the conference. That's why Monocarp decided to pin some of them. Monocarp can pin any number of messages, and if he wants anyone to read some message, he should pin it — otherwise it will definitely be skipped by everyone. Unfortunately, even if a message is pinned, some students may skip it anyway. For each student $ i $ , Monocarp knows that they will read at most $ k_i $ messages. Suppose Monocarp pins $ t $ messages; if $ t \le k_i $ , then the $ i $ -th student will read all the pinned messages; but if $ t > k_i $ , the $ i $ -th student will choose exactly $ k_i $ random pinned messages (all possible subsets of pinned messages of size $ k_i $ are equiprobable) and read only the chosen messages. Monocarp wants to maximize the expected number of students that read their respective messages (i.e. the number of such indices $ i $ that student $ i $ reads the message $ m_i $ ). Help him to choose how many (and which) messages should he pin!输入输出格式
输入格式
The first line contains one integer $ n $ ( $ 1 \le n \le 2 \cdot 10^5 $ ) — the number of students in the conference. Then $ n $ lines follow. The $ i $ -th line contains two integers $ m_i $ and $ k_i $ ( $ 1 \le m_i \le 2 \cdot 10^5 $ ; $ 1 \le k_i \le 20 $ ) — the index of the message which Monocarp wants the $ i $ -th student to read and the maximum number of messages the $ i $ -th student will read, respectively.
输出格式
In the first line, print one integer $ t $ ( $ 1 \le t \le 2 \cdot 10^5 $ ) — the number of messages Monocarp should pin. In the second line, print $ t $ distinct integers $ c_1 $ , $ c_2 $ , ..., $ c_t $ ( $ 1 \le c_i \le 2 \cdot 10^5 $ ) — the indices of the messages Monocarp should pin. The messages can be listed in any order. If there are multiple answers, print any of them.
输入输出样例
输入样例 #1
3
10 1
10 2
5 2
输出样例 #1
2
5 10
输入样例 #2
3
10 1
5 2
10 1
输出样例 #2
1
10
输入样例 #3
4
1 1
2 2
3 3
4 4
输出样例 #3
3
2 3 4
输入样例 #4
3
13 2
42 2
37 2
输出样例 #4
3
42 13 37