fast input out using buffer class

 /* package codechef; // don't place package name! */


import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.lang.reflect.Array;

import java.util.StringTokenizer;

import java.util.Arrays;


class judge_chef_contest {

    static class FastReader {

        BufferedReader br;

        StringTokenizer st;


        public FastReader()

        {

            br = new BufferedReader(

                    new InputStreamReader(System.in));

        }


        String next()

        {

            while (st == null || !st.hasMoreElements()) {

                try {

                    st = new StringTokenizer(br.readLine());

                }

                catch (IOException e) {

                    e.printStackTrace();

                }

            }

            return st.nextToken();

        }


        int nextInt() { return Integer.parseInt(next()); }


        long nextLong() { return Long.parseLong(next()); }


        double nextDouble()

        {

            return Double.parseDouble(next());

        }


        String nextLine()

        {

            String str = "";

            try {

                str = br.readLine();

            }

            catch (IOException e) {

                e.printStackTrace();

            }

            return str;

        }

    }

    public static void main(String[] args) throws IOException {

        try {

            FastReader sc = new FastReader();

            int t = sc.nextInt();

            int alices_sum=0;

            int bobs_sum=0;

            while (t-- > 0) {

                int N = sc.nextInt();

                int B[] = new int[N];

                int A[] = new int[N];

                for (int i=0;i<N;i++)

                {

                    A[i]=sc.nextInt();

                }

                for (int i=0;i<N;i++)

                {

                    B[i]=sc.nextInt();

                }

                int sumb=0,suma=0;

                Arrays.sort(A);

                Arrays.sort(B);

                for (int i=0;i<N-1;i++)

                {

                    suma = suma + A[i];

                    sumb = sumb +B[i];

                }

                if (suma<sumb)

                    System.out.println("Alice");

                else if (suma>sumb)

                    System.out.println("Bob");

                else

                    System.out.println("Draw");

}

        }

        catch (Exception e) {

            return;

        }

    }}

Comments

Popular posts from this blog

priority_queue

css in phone