Uva-11078-open Credit System (Application of high efficiency algorithm!!) )

Source: Internet
Author: User

UVA-11078

Open Credit System
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

Submit Status

Description

Problem E
Open Credit System
Input:
standard input

Output: Standard Output

In an open credits system, the students can choose any course they as, but there is a problem. Some of the students is more senior than other students. The professor of such a course have found quite a number of such students who came from senior classes (as if they came to Attend the pre requisite course after passing a advanced course). But he wants to does justice to the new students. So, he's going to take a placement test (basically an IQ test) to assess the level of difference among the students. He wants to know the maximum amount of score, a senior student gets more than any junior student. For example, if a senior student gets the and a junior student gets, then this amount is 10. Be careful that we don ' t want the absolute value. Help the professor into figure out a solution.

Input
Input consists of a number of test cases T (less than 20). Each case starts with a integer n which is the number of students in the course. This value can is as large as 100,000 and as low as 2. Next n lines contain n integers where the i' th integer is the score of the i' th student. All these integers has absolute values less than 150000. If I < J, then i' th student are senior to the J' th student.

Output
For each test case, the output of the desired number in a new line. Follow the format shown in Sample Input-output section.

Sample input Output for sample input
                     

80
3
-1

Problemsetter:mohammad Sajjadhossain

Special Thanks:shahriar Manzoor

Source


Root:: Prominent problemsetters:: Mohammad Sajjad Hossain
Root:: Competitive programming 2:this increases the lower bound of programming contests. Again (Steven & Felix Halim):: Problem Solving Paradigms:: Complete Search:: Iterative (the easier Ones)
Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: Problem Solvi Ng Paradigms:: Complete Search:: Iterative (one Loop, Linear Scan)
Root:: AOAPC i:beginning Algorithm Contests--Training Guide (Rujia Liu):: Chapter 1. Algorithm Design:: Designing Efficient Algorithms:: Examples




AC Code:






Uva-11078-open Credit System (Application of high efficiency algorithm!!) )

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.