Ural 1021 Sacrament of the sum

Ural 1021 Sacrament of the sum
Use a hash table to reflect two lists of numbers.
It seems that each number cannot be less that -32768 and cannot be more that 32767.But I heard that it was not true."maxn" should be 100000,I suggest.Or you can try to find it...
Here is my code:
#include < iostream >
#include
< string .h >
#define  maxn 100000
using   namespace  std;
long  n,m;
bool  a[ 2 * maxn + 7 ],b[ 2 * maxn + 7 ];
long  f( long  x)
{
    
return  x + maxn + 1 ;
}
int  main()
{
    
/*
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    //
*/
    memset(a,
false , sizeof (a));
    memset(b,
false , sizeof (b));
    cin
>> n;
    
for ( long  i = 1 ;i <= n;i ++ )
    {
        
long  t;
        cin
>> t;
        a[f(t)]
= true ;
    }
    cin
>> m;
    
for ( long  i = 1 ;i <= n;i ++ )
    {
        
long  t;
        cin
>> t;
        b[f(t)]
= true ;
    }
    
for ( long  i =- maxn;i <= maxn;i ++ )
        
if (a[f(i)] && b[f( 10000 - i)])
        {
            cout
<< " YES " << endl;
            
return   0 ;
        }
    cout
<< " NO " << endl;
return   0 ;
}


你可能感兴趣的:(Ural 1021 Sacrament of the sum)