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

plz. help! why WA1??
Posted by Knight 8 Nov 2007 14:01
I don't understand why WA1... on my comp first test show "YES"....
here is my code (C++)

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
bool mas1[65536],mas2[65536];
int main()
{
    //bool mas1[65536],mas2[65536];
    long int n,m,i,k,fl=0,j;
    //ifstream cin("input.txt");
    for(i=0;i<65536;i++) {mas1[i]=false;mas2[i]=false;}
    cin>>n;
    for(i=0;i<n;i++) {cin>>k; mas1[k+32768]=true;}
    cin>>m;
    for(i=0;i<m;i++) {cin>>k; mas2[k+32768]=true;}

    for(i=0;i<65536;i++)
    {
        if(mas1[i]==true)
        {
            j=75536-i;
            if(j<65536)
            {
                if(mas2[j]==true) {fl=1;break;}
            }
        }
    }
if(fl==1) cout<<"YES"<<endl; else cout<<"NO"<<endl;
return 0;
}

Edited by author 08.11.2007 14:03