FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the speeds are decreasing.
Input contains data for a bunch of mice, one mouse per line, terminated by end of file.
The data for a particular mouse will consist of a pair of integers: the first representing its size in grams and the second representing its speed in centimeters per second. Both integers are between 1 and 10000. The data in each test case will contain information for at most 1000 mice.
Two mice may have the same weight, the same speed, or even the same weight and speed.
Your program should output a sequence of lines of data; the first line should contain a number n; the remaining n lines should each contain a single positive integer (each one representing a mouse). If these n integers are m[1], m[2],..., m[n] then it must be the case that
W[m[1]] < W[m[2]] < ... < W[m[n]] and S[m[1]] > S[m[2]] > ... > S[m[n]]
In order for the answer to be correct, n should be as large as possible.
All inequalities are strict: weights must be strictly increasing, and speeds must be strictly decreasing. There may be many correct outputs for a given input, your program only needs to find one.
翻译:
FatMouse 认为老鼠越胖,它跑得越快。为了反驳这一点,你需要获取一组小鼠的数据,并将尽可能大的数据子集放入一个序列中,以便权重增加,但速度降低。
输入包含一组小鼠的数据,每行一个小鼠,以文件结尾终止。特定小鼠的数据将由一对整数组成:第一个表示其大小(以克为单位),第二个表示其速度(以厘米/秒为单位)。这两个整数都在 1 到 10000 之间。每个测试用例中的数据最多包含 1000 只老鼠的信息。两只老鼠可能具有相同的重量、相同的速度,甚至相同的重量和速度。
你的程序应该输出一系列数据;第一行应该包含一个数字 n;剩下的 n 行每行都应该包含一个正整数(每行代表一只小鼠)。如果这 n 个整数是 m[1], m[2],..., m[n] 那么它一定是这样的W[m[1]] < W[m[2]] < ... < W[m[n]] 和 S[m[1]] > S[m[2]] > ... > S[米[n]]。为了使答案正确,n 应尽可能大。所有的不等式都是严格的:重量必须严格增加,速度必须严格减少。对于给定的输入,可能有许多正确的输出,你的程序只需要找到一个。