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 ;}