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

Check your tests!
Posted by FrancaiS 11 Sep 2007 20:02
This is my solution:
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n1 = in.nextInt();
int[] a = new int[n1];
for (int i = 0; i < n1; i++) a[i] = in.nextInt();
// Arrays.sort(a);
int n2 = in.nextInt();
int[] b = new int[n2];
for (int i = 0; i < n2; i++) b[i] = in.nextInt();
// Arrays.sort(b);
boolean res = false;
for (int i = 0; i < n1; i++)
if (Arrays.binarySearch(b, 10000 - a[i]) >= 0) res = true;
if (res) out.println("YES");
else out.println("NO");
out.flush();
It have got WA on test#3
After uncommenting sorting I have got AC.
But by the data I must not sort arrays, because its sorted.
Am I wrong?

Edited by author 11.09.2007 20:08