ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1021. Sacrament of the Sum

WA in test 4
Posted by Carbon 9 Apr 2007 19:39
My code must pass in all tests but it falls in 4

#include <iostream.h>

int main()
{
bool array[65536];
for (int i=0;i<65536;i++)
  array[i]=false;
int num;
int N1,N2;
cin>>N1;
for (int i=0;i<N1;i++)
{
cin>>num;
array[num+32768]=true;
}
cin>>N2;
bool found=false;
for (int i=0;i<N2;i++)
{
cin>>num;
if (!found)
found=array[42768-num];
}
cout<<((found)?("YES"):("NO"));
return 0;
}
Re: WA in test 4
Posted by KIRILL(ArcSTU) 9 Apr 2007 20:21
........
bool array[165536];   //here zero by default
int main()
{
//for (int i=0;i<65536;i++)
//array[i]=false;
......

42768+32768>65536
Re: WA in test 4
Posted by Alias (Alexander Prudaev) 9 Apr 2007 22:55
do not declare array as local variables.
it can be cause of stack oferflow (crash)