Pagini recente » Cod sursa (job #1429985) | Cod sursa (job #199810) | Cod sursa (job #460711) | Cod sursa (job #299357) | Cod sursa (job #1038631)
#include <fstream>
#include <tr1/unordered_map>
using namespace std;
tr1 :: unordered_map < int , int > H;
int N,L,v[1030];
inline void Read()
{
int i;
ifstream fin("oite.in");
fin>>N>>L;
for(i=1;i<=N;i++)
fin>>v[i];
fin.close();
}
inline void Solve()
{
int i,j,k,sol=0;
for(i=1;i<N;i++)
{
for(j=i+1;j<=N;j++)
if(H.count(L-v[i]-v[j]))
sol+=H[L-v[i]-v[j]];
for(k=1;k<i;k++)
H[v[i]+v[k]]++;
}
ofstream fout("oite.out");
fout<<sol<<"\n";
fout.close();
}
int main()
{
Read();
Solve();
return 0;
}