WOUT - Editorial

for integer value of constraints answer can be large more than integer limit that’s why you got WA it is advice to keep everything in long long for every question from now on :slight_smile:


thanx for looking into the problem @admin123 but i did try long long as well link and still WA

@admin…but if long long int is required only by 2 or 3 variable why we declare all variable long long int…it slow down solution…because that can not handle at time in 64-bit machine it require double time compare int calculation because long long int 128-bit long variable cpu stored it into two-place and do calculation which simply increase the time required by machine to variable manipulation and calculation…
I think it is not good advice…you should only be aware which variable might get value out of range of int[-2^16 2^16-1]
integer range is quite long no need too worry much

This was demonstrated in the first pseudocode of the editorial. Notice that:

  • This code clearly runs in O(N) time.
  • This code computes all C[i=hj+1] and C[i=lj] (for all j).
  • This only needs to be run once, at the beginning.


Dude please tell me the easy way, this editorial has just crossed my head.

also, if you know more questions like this please let me know. Thanks in advance for that

can you please explain your code?

yes … tutorials are given to make things easier … but some tutorials
uses so much extra things which are really not required . .

@rcsldav yes