Cod sursa(job #3249520)

Utilizator Mihai_AritonMihai Ariton Mihai_Ariton Data 16 octombrie 2024 19:36:48
Problema Oite Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <bits/stdc++.h>
#define int long long
using namespace std;

int v[2005];
unordered_map<int, int>f;
signed main()
{
    ifstream cin("oite.in");
    ofstream cout("oite.out");
    
    int n, s=0, k, x;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            x=k-(v[i]+v[j]);
            s=s+f[x];
        }
        for(int j=1; j<=i-1; j++)
        f[v[i]+v[j]]++;
    }
    cout<<s;

    return 0;
}