[ create a new paste ] login | about

Link: http://codepad.org/6V24xT7F    [ raw code | output | fork ]

hoaithu.melody - C++, pasted on Jun 13:
import java.util.Scanner;
public class Solution {
static long A[];
static int kiux[];
static int kiuy[];
static int kius[];
static int l,r;
static long sum;
	public static void main(String[] args)  {
		//System.setIn(new FileInputStream("arraygame.txt"));
		Scanner sc=new Scanner(System.in);
		int T=sc.nextInt();
		for (int t = 1; t <=T; t++) {
			int n=sc.nextInt();
			A=new long[n];
			kiux=new int [100000];
			kiuy=new int[100000];
			kius=new int[100000];
			for (int i = 0; i < A.length; i++) {
				A[i]=sc.nextInt();
			}
			l=-1;r=-1;
			push(0,A.length-1,0);
			int kt=0;
			while(l!=r){
				pop();
				int x=kiux[l];
				int y=kiuy[l];
				int s=kius[l];
				if(check(x, y)){
					long sum1=0;
					for (int i = x; i <y; i++) {
						sum1=sum1+A[i];
						if(sum1==sum/2){
							push(x,i,s+1);
							push(i+1,y,s+1);
                            break;
						}
					}
				}
			}
			
			//System.out.println();
			 System.out.println(kius[l]);
		}
	}
	static boolean check(int x, int y){
		 sum=0;
		for (int i= x; i <= y; i++) {
			sum=sum+A[i];
		}
		if(sum%2==1) return false;
		return true;
	}
	static void push(int x,int y, int s){
		kiux[++r]=x;
		kiuy[r]=y;
		kius[r]=s;
	}
	static void pop(){
		l++;
	}
}


Output:
1
2
Line 1: error: 'import' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: