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


Why is thIS CORRECT solution getting WA for GMEDIAN?

This is my solution which only got 5 points,I did everything right, then why I did not get 30 points? I used the Fermat Modulo Theorem to calculate (n C r) % p :-

asked 13 Nov '18, 18:13

karangreat234's gravatar image

accept rate: 0%

edited 13 Nov '18, 18:32

Your solution is passing only the first sub-task because it is computing the good subsequence of even length incorrectly. (There are no duplicates in the first sub-task, hence the number of good subsequence of even length is zero).

Here's a test case on which your program is failing.



1 2 2 2 3

The correct answer should be (16+8) 24, but your program falsely returns the answer as (16+6) 22.

Here's my implementation (In case you want to compare your output on custom inputs).


answered 13 Nov '18, 19:20

masood786's gravatar image

accept rate: 13%

edited 13 Nov '18, 19:22

Let a1=1; a2=2; a3=2; a4=2; a5=5;

The good even subsequences are:- {2,2} {2,2} {1,2,2,3} {1,2,2,2} {1,2,2,3} {2,2,2,3}

Which are the other two I am missing ?

One of them I found out is : - {a1,a2,a4,a5}

Which is the other one I missed? Oh, I got it, its, {a2,a4}; Thankyou,verymuch!

(13 Nov '18, 20:05) karangreat2345★
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 13 Nov '18, 18:13

question was seen: 165 times

last updated: 13 Nov '18, 20:05