Pagini recente » Cod sursa (job #3203390) | Cod sursa (job #2310914) | Cod sursa (job #181251) | Cod sursa (job #1913897) | Cod sursa (job #3276476)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define int long long
ifstream fin("oite.in");
ofstream fout("oite.out");
const int Nmax=1050;
int a[Nmax];
unordered_map<int,int> sume[Nmax];
unordered_map<int,int> tot;
signed main()
{
int n,L;
fin>>n>>L;
for(int i=1;i<=n;i++) fin>>a[i];
for(int i=1;i<=n;i++)
{
for(int j=1;j<i;j++)
{
tot[a[i]+a[j]]++;
sume[i][a[i]+a[j]]++;
sume[j][a[i]+a[j]]++;
}
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<i;j++)
{
int sum=a[i]+a[j];
int need=L-sum;
int cnt=tot[need]-sume[i][need]-sume[j][need];
///cout<<sum<<' '<<need<<' '<<cnt<<' '<<i<<' '<<j<<'\n';
if(a[i]+a[j]==need) cnt++;
ans+=cnt;
}
}
fout<<ans/6<<'\n';
return 0;
}