Mai intai trebuie sa te autentifici.

Cod sursa(job #1797029)

Utilizator CiurezAndreiCiurez Marius-Andrei CiurezAndrei Data 3 noiembrie 2016 22:43:26
Problema Oite Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("oite.in");
ofstream fout("oite.out");

int solution;
int v[2048], N, L;
unordered_map<int, int>H;

int main()
{
    fin >> N >> L;

    for(int i = 1; i <= N; i ++)
    {
        fin >> v[i];
    }

    for(int i = 1; i < N; i ++)
    {
        for(int j = i + 1; j <= N; j ++)
        {
            if(  L - v[i] - v[j] > 0)
            {
                solution  += H[ L - v[i] - v[j] ];
            }
        }
        for(int j = 1; j < i; j ++)
        {
            H[ v[i] + v[j] ] ++;
        }
    }

    fout << solution;

    return 0;
}