×

# Why is thIS CORRECT solution getting WA for GMEDIAN?

 1 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 :- https://www.codechef.com/viewsolution/21540233 asked 13 Nov '18, 18:13 -863●9 accept rate: 0%

 1 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 5 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). https://www.codechef.com/viewsolution/21520655 answered 13 Nov '18, 19:20 106●3 accept rate: 13% 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)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×900
×477
×67
×9

question asked: 13 Nov '18, 18:13

question was seen: 165 times

last updated: 13 Nov '18, 20:05