Cod sursa(job #3238079)

Utilizator EricRaiaEricRaia EricRaia Data 18 iulie 2024 16:41:01
Problema Oite Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>
#include <unordered_map>

using namespace std;

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

int n,m,v[1025],s;
unordered_map <int, int> map;

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++)
            if(map.find(m-v[i]-v[j])!=map.end())
                s+=map[m-v[i]-v[j]];
        for(int j=0;j<i;j++)
            map[v[i]+v[j]]+=1;
    }
    cout<<s;

    return 0;
}