I want help

I want help in my programs as I am new to programming most of the times i program is correct as my compiler is showing correct output and also by costume input in codechef but on submitting it is showing wrong answer.
Please reply to my post then i will show you my programs
Please help guys.

2 Likes

I can help you, but your recent submissions are for an ongoing contest so I can’t help you. Don’t worry we also get a lot of wrong answers. Just try your best to come up with edge cases, reread the question etc.
Even when you get better you’ll have a lot of wrong answers.



4 Likes

Don’t worry bro, it happens with all of us. But do not stop trying , keep trying. Try to solve the problems which are for beginners,it will give you confidence,if you face any problem just put that in discuss forum,where many of us will let you know where you are lagging. I know inspite of trying hard if we don’t get that green tick on our solution, its really frustrating, but sometimes due to small small mistakes we got wrong answer after submissions. Just check out whether your programme satisfies all the mention constraints or not.

Contradictory statements. If you are new, you are bound to make mistakes. There is nothing wrong in that. The important point is, you should learn from your mistakes so as to not repeat them again.

2 Likes

They are not contradicting. Yes, a new programmer makes more mistakes, but he isn’t bound to make mistakes.

2 Likes

https://www.codechef.com/viewsolution/30550038

can you tell me the problem in this program.
Please

https://www.codechef.com/viewsolution/30004996
buddy, In this program for every team my goal difference is also correct, answer for given examples i is also coming correct but online judge is showing wrong answer.
Please help me find the error.
You can check the program different value by deleting some comments.

Try

1
6 4
1 2 3 3 2 2
0 3 1 1 1 1

You can’t just check whether price is 0. You need to check whether there is a basket or not.

https://www.codechef.com/viewsolution/30600893
Buddy its is still showing wrong answer.

I honestly cannot understand how half your code is working.
what is np[j]=n[f]=0;? n is an integer and f is an array. I don’t know how this doesn’t cause a compilation error. Maybe I’m missing n the array and f the integer? idk.also, you’re checking f[i] against all nf[j], but it’s not initialised, there are garbage values in the array

        nf[0]=f[0];
       // cout<<nf[0]<<endl;
        for(i=0;i<n;i++)
        {
            c=0;
            for(j=0;j<m;j++)
            {
                np[j]=n[f]=0;
                if(nf[j]==f[i])
                {
                    c=1;
                    break;
                }
            }
            if(c==0)
            {
                nf[x]=f[i];
                x++;
            }
        }

only nf[0] has a value.
Then you are adding values to np[j]

for(j=0;j<x;j++)
        {   
          
            for(i=0;i<n;i++)
            {
                if(nf[j]==f[i])
                  np[j]+=p[i];
            }
             // cout<<nf[j]<<" "<<np[j]<<endl;
        }

But np[j] is not initialised with any values.
How this code works is beyond my scope.
So here’s a failing testcase

2
6 50
50 1 3 3 2 2
5 3 1 1 1 1
6 50
50 1 3 3 2 2
5 3 1 1 1 1

Also I just initialised all your variables and declared them in the while loop and it got AC. How and why is beyond me.
I’ve easily spent half an hour trying to understand what’s going on.
https://www.codechef.com/viewsolution/30601018

Test cases given in problem are sample cases. Sometimes program shows correct output for given test cases but it may fail with some other cases. This shows wrong answer while submitting.
Check the constraints.
I have solved this using Java otherwise I would have been able to help you.

Actually f[n] == n[f] == *(f+n). That’s the reason it doesn’t give a compilation error. :slight_smile:

3 Likes

Oh thanks, i was so confused. But isn’t that out of bounds given n can be 50?

Yes, obviously. Maybe, he meant to write i[f];