Uva507-Jill rides again

Source: Internet
Author: User

Question link: http://uva.onlinejudge.org/index.php? Option = com_onlinejudge & Itemid = 8 & page = show_problem & problem = 448

Pay attention to the following situations for this question. For details, refer to the code.

If more than one segment is maximally nice, choose the one with the longest cycle ride (largest j-i).To break ties in longest maximal segments,choose the segment that begins with the earliest stop(lowest i)

Typical maximum child segments and problems.

# Include <iostream> using namespace STD; int main () {int testnumber; // number of tests CIN> testnumber; For (INT Index = 1; index <= testnumber; index ++) // cyclically test each group of data {int max = 0, sum = 0, tempnumber = 0; int tempstart = 0; int start = 0, end = 0; int number; CIN> Number; For (INT I = 0; I <number-1; I ++) {CIN> tempnumber; sum + = tempnumber; if (sum <0) // if it is less than 0, the previous value is temporarily abandoned and the next value is used as the starting point {tempstart = I + 1; sum = 0 ;} if (sum> max | (sum = max & START = tempstart) // {max = sum; Start = tempstart is updated only when the value is greater than the maximum value; end = I ;}}if (max = 0) cout <"Route" <index <"has no nice parts" <Endl; else cout <"the nicest part of Route" <index <"is between stops" <start + 1 <"and" <End + 2 <Endl;} return 0 ;}

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.