You are not logged in. Please login at www.codechef.com to post your questions!

×

can you plz tell why this code showing nzec

Code for the pproblem : http://www.codechef.com/problems/CLEANUP

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--;
    }
}

}

asked 15 Mar '14, 04:49

harishmohanani's gravatar image

1★harishmohanani
-312
accept rate: 0%

edited 15 Mar '14, 16:18

kcahdog's gravatar image

3★kcahdog
10.0k2854129


@harishmohanani, bro from my experience, here you wont get the answer for your above tl;dr code. reasons, imho:

1 - code is not clear and simple

2 - no link to the problem

3 - intention is not clear

etc.

and after checking your profile, i realized that 1st you got nzec and then AC. you should close the question after AC or mention here that you got AC. the forum is not for "fix my bugs" purpose. you have to google your bug or see other AC codes before bothering others. my downvote goes to you for your laziness, sorry.

link

answered 15 Mar '14, 06:52

garakchy's gravatar image

1★garakchy
1.1k163048
accept rate: 1%

the link to the problem stmt http://www.codechef.com/problems/CLEANUP

It is working on my machine perfectly

link

answered 15 Mar '14, 15:46

harishmohanani's gravatar image

1★harishmohanani
-312
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,302
×422
×125

question asked: 15 Mar '14, 04:49

question was seen: 1,096 times

last updated: 15 Mar '14, 16:18