Cod sursa(job #3239547)

Utilizator nicushor21Pirlog Marian Nicolae nicushor21 Data 6 august 2024 13:32:21
Problema Oite Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("oite.in");
ofstream fout("oite.out");
int n,s,i,j,v[1025],aux,k,l;
long long cnt;
unordered_map<int,int> mp;
int main()
{
    mp.clear();
    fin>>n>>s;
    for(i=1;i<=n;i++)
        fin>>v[i];
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++)
            cnt += mp[s-v[i]-v[j]];
        for(j=1;j<i;j++)
            mp[v[i]+v[j]]++;
    }
    fout<<cnt;
    return 0;
}