Doubt in Encoding December 2020 - ENCDEC5

I don’t understand why it is giving wrong answer for my code in Question ENCDEC5,
can anyone please help me??

link for my solution -

You don’t need the first and third operation, you can just apply the operation arr[i]+=arr[i]\%3. Also, consider the final array as : [3, 6, 7, 7, 7, 8] and f = 7, you will output 7, 7 but output should be 6, 8.

yes sir you’re right, thank you for replying :relaxed:

Don’t call me “sir”, that title looks good on Red coders only.

Hello “Sir”,
I’m a noob so please help me with few of my doubts,

This is one of my solution

I want to know what do coders like you do to stop facing problems like time limit and runtime?

Sometimes I solve the question but my submission never gets accepted because of the time or runtime which is basically due to memory problems most of the time.

You helped me before so please do one more favor to me and explain me how to declare the array or vector so that it takes enough memory and which tricks you guys use like I noticed :

use of unsigned main instead in int main
use of long long instead of int
pasting that cin.tie(NULL) in every code

Thank you

1 Like

Search about time complexity and around 1e6-1e7 operations happen in 1sec.

Always see the maximum size which it can take and declare the array according to that.


This is for fast input and output

Just google these things and you will know