HDU 1594 (find the max) (absolute value maximum value compare size)

Source: Internet
Author: User

Find the max Time Limit: 1000/1500 MS (Java/others) memory limit: 32768/32768 K (Java/Others) Total submission (s): 624 accepted submission (s): 292

Problem description has a discrete function f (x), x = {1, 2, n}, f (x) <2 ^ 31. Now we need to find two vertices I, j, so that the points between the two points of the function are all under the two points of the line, and the greater the absolute value of the slope of the line, the better.
Input includes multiple test instances. Each test instance contains two rows. The first behavior is an integer of N, 2 <=n <= 100000, followed by N integers f (x), x = 1, 2... n, until the end of the file is read.
Output outputs the I and j found for each test instance. If there are multiple answers, the output Lexicographic Order is the smallest.
Sample Input
 
31 2 332 6 4

Sample output
 
1 21 2HintHint Use scanf to avoid time limit exceeded

Author8600
Sourcehdu 2007-spring Programming Contest-warm up (1) Question: The given value is an ordinate, And the abscissa is a continuous integer starting from 1 by default. The question is to solve the point with the largest absolute value so that all points between the selected two points are under a straight line. Other points are not considered. Difficulty: Read the question, understand the meaning of the given coordinates, and understand the meaning of the question. Ice_alone would like to thank the two teammates for their help. The Code is as follows:
 
# Include <stdio. h> # include <stdlib. h> int main () {int N; while (~ Scanf ("% d", & N) {int A, B, Max, M, k = 1, C, I; scanf ("% d ", & A, & B); max = ABS (a-B); for (I = 2; I <n; I ++) {scanf ("% d ", & C); M = ABS (C-B); If (M> MAX) {max = m; k = I;} B = C ;} printf ("% d \ n", K, k + 1);} 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.