How to think about problems and solve problems ZKC seniors ' welfare

Source: Internet
Author: User

Title Description is a year of ACM training time, ZKC Seniors invited n students to play a prize-winning game. First, he let each classmate on the left, the right hand above each write an integer, ZKC seniors himself also on the left, right hand each write an integer. Then, let these n students in a row, ZKC seniors standing in front of the team. After the team, all the students will get ZKC seniors distribution of a number of floss cakes, each classmate to obtain the number of floss cakes are: the students in front of the left hand of the number of the product divided by the number of his own right hand, and then down to get the result of the whole. ZKC Seniors do not want a particular student to get extra benefits, so he would like to ask you to help him reschedule the order of the team, so that the most benefit of the students, the benefits as little as possible. Note that the position of ZKC seniors is always at the front of the team. "Data range" for% of data, with 1≤n≤1, the,0< A, b <10000Enter the first line an n means the number of N students the second row two digits represents the ZKC seniors left and right hand numbers the next n lines represent the nth classmate the left hand and the right hand digital output a number representing the benefit of the most classmates obtained welfare sample input31 12 37 44 6Sample Output2Tip Press 1,2, the number of 3rd students to arrange the team, the most benefit of the students get the meat floss cake 2; press 1,3, 2 Such ranks, the most benefit of the students get the meat floss cake number is 2; press 2,1, 3 Such ranks, the most benefit of the students get the meat floss cake number is 2; press 2,3, 1 Such ranks, the most benefit of the students get the meat floss cake number is 9; Press 3,1, 2 Such ranks, the most benefit of the students get the meat floss cake number is 2; Press 3,2, 1 The ranks of the group, the most benefit of the students get the meat floss cake number is 9. Therefore, the most well-off students get at least 2 floss cake, the answer output 2. 

The most important words are ranked in front of the students on the left hand number of the results divided by this classmate's right hand number is the number of cookies the classmate should have.

Now if a is in front of B then the number of loaves obtained by a T/R.A B is t*la/rb

Now, if B is in front of a, then B gets the number of loaves t/r.b a gets, the number of loaves is T*lb/ra

Suppose a must be in front of B so it must be deduced. An expression with four variables is used for sorting

Now the key is why a must be in front of b the outermost reason is that in order to get the largest number of biscuits to get the biscuits as little as possible

So the problem can be simplified for all the classmates in front of the left hand just a a hand that a hand above the number is B front of all the classmates left-handed product so now simplify for two people problem. The same person is in front of the number of cakes or the amount of cake in the back to get more than the number of cakes. It's obviously in the back, so why a is in front of b because of the t*la/rb<t*lb/ra (so the biggest number is as small as possible)

How to think about problems and solve problems ZKC seniors ' welfare

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.