Average

All submissions for this problem are available.
You are given a sequence of integers $a_1, a_2, ..., a_N$. An element ak is said to be an average element if there are indices $i, j$ (with $i \neq j$) such that $a_k = \frac{a_i + a_j}{2}$. In the sequence $$3 \quad 7 \quad 10 \quad 22 \quad 17 \quad 15$$ for $i=1, j=5$ and $k=3$, we get $a_k = \frac{a_i + a_j}{2}$. Thus $a_3 = 10$ is an average element in this sequence. You can check that $a_3$ is the only average element in this sequence. Consider the sequence $$3 \quad 7 \quad 10 \quad 3 \quad 18$$ With $i=1, j=4$ and $k=1$ we get $a_k = \frac{a_i + a_j}{2}$. Thus $a_1=3$ is an average element. We could also choose $i=1, j=4$ and $k=4$ and get $a_k = \frac{a_i + a_j}{2}$. You can check that $a_1$ and $a_4$ are the only average elements of this sequence. On the other hand, the sequence $$3 \quad 8 \quad 11 \quad 17 \quad 30$$ has no average elements. Your task is to count the number of average elements in the given sequence. ###Input: The first line contains a single integer $N$ indicating the number of elements in the sequence. This is followed by $N$ lines containing one integer each (Line $i+1$ contains $a_i$). (You may assume that $a_i + a_j$ would not exceed `MAXINT` for any $i$ and $j$). ###Output: The output must consist of a single line containing a single integer $k$ indicating the number of average elements in the given sequence. ###Constraints:  You may assume that $1 \leq N \leq 10000$.  In $30 \%$ of the inputs $1 \leq N \leq 200$.  In $60 \%$ of the inputs $1 \leq N \leq 5000$. ###Sample Input 1: 6 3 7 10 17 22 15 ###Sample Output 1: 1 ###Sample Input 2: 5 3 7 10 3 18 ###Sample Output 2: 2 ###Sample Input 3; 5 3 8 11 17 30 ###Sample Output 3: 0Author:  admin2 
Date Added:  17092018 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions