Operational Amplifiers
Operational amplifiers are electronic devices that allow the execution of arithmetic operations between their input analog signals. A specific category of operational amplifiers is the adders, in which two input cables are connected, carrying two signals in the form of electric current measured as a positive or negative number. Another cable provides the output as the analog sum of their input signals, again in the form of electric current. The performance of these amplifiers is particularly high for input signals whose sum is close to . For example, good performance exists for two input signals that have approximately opposite values, such as and . Operational amplifiers find extensive applications today, for instance, in mixing audio signals.
Problem
Develop a program in one of the IOI languages that takes as input integers (positive and negative) in ascending order. The program should find the two numbers whose sum is closest to , directing the corresponding channels to the appropriate operational amplifier.
Input File
The input file named operators.in is a text file with the following structure: The first line contains the integer , the number of integers. The second line contains exactly integers, in ascending order, separated by spaces. For each such number it will hold that , and additionally .
Output File
The output file named operators.out is a text file with the following structure: It has one line with exactly two integers separated by a space. These numbers are the two numbers from the operators.in file whose sum is closest to , first the smaller of the two and then the larger of the two.
Notes
- If there are more than one pair of numbers with the same optimal sum, choose any.
- The numbers can all be positive or all negative.
- The two numbers in the output file must also be in ascending order.
Examples of Input - Output Files:
1st
STDIN (operators.in)
10
-101 -4 -1 6 95 1000 1001 1002 2000 9999
STDOUT (operators.out)
-4 6
2nd
STDIN (operators.in)
10
-110 -22 -1 28 35 105 140 145 200 300
STDOUT (operators.out)
-110 105
Maximum execution time: 3 sec.
Maximum available memory: 64 MB.
For % of the test cases, .
Comments