Sum of Pairs
A sequence of integers is given.
We want to be able to answer the question "Is there a pair of terms in the sequence whose sum equals
?" for any integer
.
Problem
Write a program in one of the IOI languages that reads the sequence of numbers and then answers a series of such questions, for different values of
.
If the answer is "yes", then your program should print the word "
"; otherwise, it should print the word "
".
Input Files:
The input files named sumpair.in are text files consisting of three lines: The first line contains two integers separated by a single space: the number of sequence numbers
and the number
of questions
.
The second line contains
integers (the absolute value of which does not exceed
), separated in pairs by a single space: the terms of the sequence.
The third line contains
integers separated in pairs by a single space: the questions to be answered.
Output Files:
The output files named sumpair.out are text files consisting of lines.
The
-th line contains the answer to the
-th question: one of the words "
" or "
".
Example of Input - Output Files:
STDIN (sumpair.in)
12 5
2 42 5 -6 5 7 10 29 0 21 29 15
17 30 42 -4 58
STDOUT (sumpair.out)
true // 2+15 = 7+10 = 17
false // it does not result in 30
true // 42+0 = 42
true // 2+(-6) = -4
true // 29+29 = 58
Formatting: In the output, each line terminates with a newline
character.
Maximum execution time: 2 sec.
Maximum available memory: 16 MB.
Comments