Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

can you plz tell why this code showing nzec

$
0
0

import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer;

class Walk {

public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    int noOfTestCases;
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pw = new PrintWriter(System.out);
    noOfTestCases = Integer.parseInt(in.readLine());

    while (noOfTestCases > 0) {

        int totalNoOfJobs;
        int noOfJobsDone;
        boolean flag = true;
        String input = in.readLine();
        StringTokenizer st = new StringTokenizer(input);
        totalNoOfJobs = Integer.parseInt(st.nextToken());
        noOfJobsDone = Integer.parseInt(st.nextToken());

        input = in.readLine();
        StringTokenizer st1 = new StringTokenizer(input);

        int[] indexOfJobDone = new int[noOfJobsDone];
        int[] chef = new int[totalNoOfJobs];
        int[] assistant = new int[totalNoOfJobs];
        int chefIndex = 0;
        int assistantIndex = 0;

        for (int i = 0; i < noOfJobsDone; i++)
            indexOfJobDone[i] = Integer.parseInt(st1.nextToken());

        Arrays.sort(indexOfJobDone);

        for (int i = 1; i <= totalNoOfJobs; i++) {

            if (Arrays.binarySearch(indexOfJobDone, i) < 0) {
                if (flag) {
                    flag = false;
                    chef[chefIndex++] = i;
                } else {
                    flag = true;
                    assistant[assistantIndex++] = i;
                }
            }
        }

        for (int i = 0; chef[i] != 0; i++)
            pw.print(chef[i] + " ");
        pw.println();
        for (int i = 0; assistant[i] != 0; i++)
            pw.print(assistant[i] + " ");
        pw.println();

        pw.flush();
        noOfTestCases--;
    }
}

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>