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

No TLE program
Posted by panfei 22 Oct 2008 14:53
program ex(input,output);
 var
  a,b:array[0..50001] of longint;
  n,i,j,m:longint;


 begin
  read(n);
  for i:=1 to n do read(a[i]);
  read(m);
  for i:=1 to m do read(b[i]);
  j:=1;
  for i:=1 to n do
   begin
    if a[i]+b[1]<10000 then begin continue;end;
    while (a[i]+b[j]>10000) and (j+1<=m) do inc(j);
    if a[i]+b[j]=10000 then begin writeln('YES');halt;end;
   end;
  writeln('NO');
 end.