ACM (UVa) : 10664



package volume_CVI;

import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Id_10664 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Scanner input = new Scanner (System.in);   
		
		String s;
		String temp;
		int m = input.nextInt();
		s = input.nextLine();
		
		while ( m != 0 ) {
			
			int array [] = new int [250];
			int i = 0 ;
			
			s = input.nextLine();
			StringTokenizer stok = new StringTokenizer (s);
			
			while ( stok.hasMoreElements()) {
				temp = stok.nextToken();
				array [i++] = Integer.parseInt(temp);
			}
			
			Arrays.sort(array);
			int hand1 = 0;
			int hand2 = 0;
			
			int j = 0;
			
			while ( j < i ) {
				
				if ( hand1 >= hand2 )
					hand2 += array [array.length - j - 1];
				
				else
					hand1 += array [array.length - j - 1];
				j++;
			}
		
			if ( hand1 - hand2 == 0 )
				System.out.println ( "YES" );
			else
				System.out.println ( "NO" );
			m--;
		}
	}
}


Advertisements

4 thoughts on “ACM (UVa) : 10664

  1. Vaiya ami apnar blog ar 1 jon niyomito member…Ami kisudin dhore UVa te java te problem solve korte chaitesi…But compile error kaitesi…Apnar ar code ta o submit kore deklam compile error dekhay…Tahole ki submit korar way ki???

  2. hi
    temon kono special way nai, amr mone hoy nicher vul gula hoche submit korte giye

    1. amar code ta theke line 01 baad diye dite hobe
    mane holo, package name deya jabe na

    2. line 07, class name hote hobe “Main” (without quote)
    java diye submit korle main class tar naam “Main” dite hobe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s