Cod sursa(job #2725293)

Utilizator Casian_doispeChiriac Casian Casian_doispe Data 18 martie 2021 18:49:23
Problema Medie Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <fstream>
#include <deque>
#include <queue>
#include <algorithm>

using namespace std;

ifstream cin ("medie.in") ;
ofstream cout("medie.out") ;

int v[9001], frecv[7001] ;

int main()
{

    int n, rez = 0 ;

    cin >> n ;

    for(int f = 1 ; f <= n ; f ++)
        cin >> v[f], frecv[v[f]] ++ ;

    for(int f = 1 ; f <= n ; f ++)
        for(int e = f + 1 ; e <= n ; e ++)
            if(!((v[f] + v[e]) % 2))rez += frecv[(v[f] + v[e]) / 2] - (v[f] == v[e]) - ((v[f] == ((v[f] + v[e]) / 2)) || (v[e] == ((v[f] + v[e]) / 2))) ;

    cout << rez ;

    return 0;

}