Where i am getting wrong

hello @Mihir163
n is redundant (that is u will never require it ),

you are given w organes.
where weight of ith organe is i kg ( note… value of i -> 1…w)
and price of ith organe is w[i]

now if w[i]==-1 that means ith orange is not available for sail.

so before applying ur algorithm .
prepare a new array from w array by remove all weights with negative price and then apply ur logic.

but see input format according to input format i have taken a input…should i take another price array,bit confusing for me

no , read as per input format only.
first n, then w.
and then
array contianing w elements(note it is w elements not n elements).

https://ide.codingblocks.com/s/266718 is mistake rectified??

no , pls refer this

read these lines carefully
image