SHARE
TWEET

Untitled

a guest Jun 14th, 2015 244 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.util.*;
  3. import java.text.*;
  4. import java.math.*;
  5. import java.util.regex.*;
  6.  
  7. public class Solution {
  8.  
  9.     public static void main(String[] args) {
  10.         Scanner s = new Scanner(System.in);
  11.         final int N = s.nextInt();
  12.  
  13.         for(int i = 0; i < N; i++) {
  14.             int NN = s.nextInt();
  15.             int[] arr = new int[NN];
  16.             for(int j = 0; j < NN; j++) {
  17.                 arr[j] = s.nextInt();  
  18.             }
  19.             System.out.println(isEven(arr) ? "YES" : "NO");
  20.         }
  21.     }
  22.    
  23.     public static boolean isEven(int[] arr) {
  24.         for (int index = 0; index < arr.length; index++) {
  25.             int difference = 0;
  26.  
  27.             for (int i = index -  1; i > -1; i--) {
  28.                 difference += arr[i];
  29.             }
  30.             for (int i = index+1; i < arr.length; i++) {
  31.                 difference -= arr[i];
  32.             }
  33.  
  34.             if (difference == 0) {
  35.                 return true;
  36.             }
  37.         }
  38.  
  39.         return false;
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top