ASC (1) G (longest rising sequence)

Source: Internet
Author: User

G-Beautiful people Time Limit:10000/5000MS (Java/others) Memory Limit:128000/64000KB (Java/others)Special JudgeSubmitstatusproblem Description

      The most prestigious sports club in one city have Exactl Y N members. Each of the's is strong and beautiful. More precisely, i-th member of this club (members being numbered by the time they entered the club) have strength Si a nd beauty Bi. Since This is a very prestigious club, it members were very rich and therefore extraordinary people, so they often extreme Ly hate each other. Strictly speaking, i-th member of the club Mr X hates J-th member of the club Mr Y if si <= Sj and BI&NBSP;&G t;= bj or if si >= sj and bi <= bj  (if both properties of Mr X is greater then Correspondi ng Properties of Mr y, he doesn ' t even notice him, on the other hand, if both of his properties is less, he respects Mr y Very much).

To celebrate a new 2003 year, the administration of the club was planning to organize a party. However they is afraid that if and people who hate each and would simultaneouly attend the party, after a drink or both They would start a fight. So no, and people who hate each and should be invited. On the other hand, to keep the club prestige at the apropriate level, administration wants to invite as many people as Pos Sible.

Being the only one among administration who isn't afraid of touching a computer, you be to write a program which would f IND out whom to invite to the party.

Input the first line of the input file contains integer n-the number of members of the club. (2≤n≤100). Next N lines contain, numbers each-sIand BIrespectively (1≤si, Bi ≤109 ). Output on the first line of the output file print the maximum number of the people that can is invited to the party. On the second line, output N integers-numbers of members to is invited in arbitrary order. If Several solutions exist, output any one. Sample Input
41 11 22) 12 2
Sample Output
21 4

Test instructions: Gives the n number to X, Y. Ask to find the longest number pair. So that each dimension is strictly incremented
Idea: The longest ascending subsequence, just 2-dimensional. You can sort by x and then maintain it sequentially with a line tree.
Detailed maintenance is the maximum length at the end of each Y-point
It is important to note that when the same first update x is in the following y in the record, all queries are updated uniformly. Since the x point is not equal to the added sequence, it can be sufficient

ASC (1) G (longest rising sequence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.