Cod sursa(job #58232)

Utilizator cos_minBondane Cosmin cos_min Data 4 mai 2007 18:53:37
Problema Oite Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <stdio.h>
#include <ext/hash_map>
using namespace std;

#define in "oite.in"
#define out "oite.out"
#define dim 1025
using namespace __gnu_cxx;

int N, L, total=0;
int V[dim];
hash_map<unsigned,unsigned> M;

int main()
{
    freopen(in,"r",stdin);
    freopen(out,"w",stdout);
    
    scanf("%d%d", &N, &L);
    for ( int i = 1; i <= N; i++ )
        scanf("%d", &V[i]);
    
    for ( int i = 3; i <= N; i++ )
    {
        for ( int j = 1; j < i-1; j++ )
            M[V[i-1]+V[j]]++;
        
        int K = L - V[i];
        
        for ( int j = i+1; j <= N; j++ )
            total += M[K-V[j]]; 
    }
    
    printf("%d", total);
}