以下是原题:
Is Bigger Smarter
Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the IQ's are decreasing.
The input will consist several cases. Each case begins with a integer N,there will be N lines, one elephant per line. Input will be terminated by the end-of-file. The data for a particular elephant will consist of a pair of integers: the first representing its size in kilograms and the second representing its IQ in hundredths of IQ points. Both integers are between 1 and 10000. The data will contain information for at most 1000 elephants. Two elephants may have the same weight, the same IQ, or even the same weight and IQ.
Say that the numbers on the i-th data line are W[i] and S[i]. 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 an elephant). If these n integers are a[1], a[2],..., a[n] then it must be the case that
W[a[1]] < W[a[2]] < ... < W[a[n]]
and
S[a[1]] > S[a[2]] > ... > S[a[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 IQs must be strictly decreasing. There may be many correct outputs for a given input, your program only needs to find one.
Sample Input
9
6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900
Sample Output
4
4
5
9
7
我姑且翻译一下吧……有不好的地方大家包涵
有人认为大象体重越重就越聪明,为了证明这是错的,你要从给定的数据当中挑出尽可能多的一列数据,这一列数据中,随着大象体重的增长,它们的智商在降低。
输入的最开始是一个整数N,接下来是N行整数,输入以EOF结束。每行包含两个整数,第一个整数是大象的体重,第二个是大象的IQ,两个整数都在1到10000之间,最多有1000只大象的数据。两只大象可以有相同的体重或相同的IQ,或者两个都一样。
假设第i行的数据是w[i]和s[i]。程序的输出应该包含几行数据,第一行是一个整数n,接下来有n行数据,每行都是一个整数(每个整数代表一只大象),假设这些数据是a[1], a[2]...a[n],那么应该有
w[a[1]] > w[a[2]] > ... >w[a[n]]
同时有
s[a[1]] > s[a[2]] > ... >s[a[n]]
为了尽可能证明你的结论是正确的,n必须尽可能大。上述不等式都是严格>或<。如果有多个结果,就任意输出其中一个。
Sample Input
9
6008 1300
6000 2100
500 2000
1000 4000
1100 3000
6000 2000
8000 1400
6000 1200
2000 1900
Sample Output
4
4
5
9
7
我没有思路,请各位赐教啊……