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

Why I have got crush?
Posted by Liceum#64_Yurik 5 Dec 2007 21:13
Why I have got crush?
#include<stdio.h>
int main ()
{
    int n1, n2, i;
    int temp;
    bool flag=false;
    bool a[35000];
    for (i=0; i<35000; i++)
        a[i]=false;
    scanf ("%i", &n1);
    for (i=0; i<n1; i++)
    {
        scanf ("%i", &temp);
        if (temp<0) temp=-temp;
        a[temp]=true;
    }
    scanf ("%i", &n2);
    for (i=0; i<n2; i++)
    {
        fscanf (f, "%i", &temp);
        if (a[10000-temp]==true) flag=true;
        if (flag == true) break;
    }
    if (flag == true) printf("YES");
    else
    printf("NO");
    return 0;
}
Re: Why I have got crush?
Posted by Madhav 13 Jun 2008 02:11
what you do is that take an bool array of length 65000.
and for every number you take as input add 33,000 or something(some offset) to make every number >=0 and then do the same thing as u did now but in this case u search for
10000+offset