java and python are slow languages that’s why codechef and all OJs provide time multipliers for them. for java its x2, and for python its x5

I know they are slower but its not mentioned anywhere in the problem. Isn’t it?

That's kind of excuse. Sorry.

Dont be, lul. Neither I owe you any explanation nor do you. Its anyways my own opinion and not the setter/admins.

Ordered statistics tree is not something beginner wants to know at first.

Thats a very subjective thing. I can argue the same for other data structures like heap, segment tree, set etc. and say they should not be given as “Beginners will want a easy problem which they can solve.”

looks easier for experienced participants.

Which is alright lol.

Lastly, if everyone solves easy problem means they are learning nothing. Personally against that.

Hmm that all mean we shouldn’t have any category in Practice section like Easy, Medium, etc! Something related to segment tree or BIT shouldn’t be in easy in that case.

Hello @prmondal the test cases were weak and you can even solve this question with any tree and hence it’s an easy question… Okay fine ?

Here is an sample soln

And btw I hope u know that all problems gets 100 points regardless of difficulty and it’s only setter who gets different amount of payment on basis of difficulty… I don’t see any point that u should have any problem… And the O(n^3) soln passes which shows it’s an easy problem

It can be solved by simple sum query Segment tree also and if you don’t even know segment tree then I don’t think you are a competitive programmer yet… It’s very popular tree… You should learn it by now then… And even if u don’t know it… It’s still solvable without it…

Chef and soccer has 1/8 times submission than this problem and it was categorised as easy medium… So what difficulty do you expect for this one ? Same ? Or medium ?

Well I know about segment tree. But for this problem I solved using BIT but after the contest though.

One thing I can agree since the constraint is weak it can be solved without any tree. But editorial does not say about it clearly.

Okay :slight_smile: @prmondal
That’s great…

If anyone found difficult solving the problem using the trees…then you can view my solution :slight_smile:

link :

import bisect as heep
from sys import stdin, stdout
def take_input():
return n,k
def take_input_list():
x=[int(x) for x in stdin.readline().split()]
return x
def main():
while i<n:
while j<n:
if x[x[b[(k-1)//((k+(j-i+1)-1)//(j-i+1))]]]>0:
return ans
for _ in range(int(input())):
if name == “main”:

My very complex solution which uses Trie :stuck_out_tongue:

haha…it’s very complex to understand …but yeah… it’s a good practice to use Data structures instead of using builtin libraries

1 Like

In the question i found that the Kth element will alaways be the largest in the subarray.

Hi, just a small doubt in tester’s solution: Why LEAFOFFSET is set to 2047? I tried to submit the same solution with different offsets(say 2031, 2046) and got WA but same code passed with 2047 as offset.

Thanks :slight_smile:

please explain the use of OFFSET in tester’s solution ?

hi, I have tried your code with some change -
I haven’t taken the pair but taken the hash array M seperately. could you help me where the problem is.

@taran_1407 Sir,Can you kindly please elaborate the prefix array usage ?What does PR[x][r] denote-Can you explain that a bit more in detail?What is x here-the xth element?
Thanks in advance…

@nilesh8757 Sir,can you kindly tell me why you are entering old value of the frequency of a[i] in PBDS?
Thanks in advance