Pagini recente » Cod sursa (job #2774939) | Cod sursa (job #1842025) | Cod sursa (job #3206726) | Cod sursa (job #8254) | Cod sursa (job #3238079)
#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;
}