Cod sursa(job #2546600)

Utilizator stefantagaTaga Stefan stefantaga Data 14 februarie 2020 12:07:46
Problema Oite Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("oite.in");
ofstream g("oite.out");
map <int,int> m;
int i,j,n,sum[2000000],q,val,v[2000005],sol;
int main()
{
    f>>n>>val;
    for (i=1;i<=n;i++)
    {
        f>>v[i];
    }
    for (i=1;i<=n;i++)
    {
        for (j=i+1;j<=n;j++)
        {
            sol=sol+m[val-v[i]-v[j]];
        }
        for (j=1;j<i;j++)
        {
            m[v[i]+v[j]]++;
        }
    }
    g<<sol;
    return 0;
}