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

I need help
Posted by Gilgames Sumer 28 Oct 2007 23:31
Here's my code, it works for every test I make, but it still gives WA on test #14

#include <stdio.h>

long a[50000],b[50000],ok=0,i,j=0,n,m;

main () {
     scanf ("%ld",&n);
     for (i=0;i<n;i++)
         scanf ("%ld",&a[i]);
     scanf ("%ld",&m);
     for (i=0;i<m;i++)
         scanf ("%ld",&b[i]);
     for (i=0;i<n;i++) {
         while ((a[i]+b[j]>10000)&&(j<m)) j++;
         if (a[i]+b[j]==10000) ok=1;}
     if (ok) printf ("YES");
     else printf ("NO");
}
Re: I need help
Posted by alexm110h 29 Oct 2007 01:17
Binary Search and accepted!