CIRMERGE - Editorial

can you please give the array at each step

8 3 10 20 6
[11, 10, 20, 6]
[10, 20, 17]
[27, 20]
[47]
102

here’s the array by the algorithm i followed

I’ve used the same approach, can you spot the mistake in my code?

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

It passes 1st, 2nd and 4th TC.

@bhagirathi08

@anonymous1918
8 3 10 20 6
[14 3 10 20] -> 14
[ 14 13 20 ] -> 14 + 13
[27 20] -> 14 + 13 + 27
[47] -> 14 + 13 + 27 + 47 =>101

well I used modulo as well :stuck_out_tongue:

1 Like

simply because he declared it globally

You have a nice knowledge of algos. Good !

2 Likes

she herself said she was an icpc silver medalist bro.

1 Like

Thanks great. I will learn more and more when people like her be active on discuss.

2 Likes

Konsa waala silver? Regionals yaa world finals? Apne yahaa India mai kuch gold/silver nhi milta for regionals😅

Why don’t you go there (where loopfree is) XD?

2 Likes

you should learn balloon popping problem. This question is very similar to that problem. Here is the link : - LeetCode

why modulus is so time consuming

I used the greedy approach that you stated will pass the Subtask #2 (with distinct powers of 2).
Can you tell me why this greedy approach gave WA for other Subtasks? For which test case my greedy approach will give WA?

Thanks in advance.

I know it only because of experience btw you can refer here - https://stackoverflow.com/questions/27977834/why-is-modulus-operator-slow

1 Like

Bade hi experienced ho aap toh :stuck_out_tongue:

2 Likes

Bs apse kuch 5-10%. Dot dot dot

1 Like

might be because of integer overflow, try having long dp[][]

1 Like

Where can we find material to read about Garsia Wachs algortihms?

What does “Linear Case” mean??