the difference easy hard version constraint in version constraint low you hack version problem solvedKoa Koala beachThe beach consist leave right shore n1 meter sea island n1 meter shoreshe measure depth sea 1 2 dot n meter shore save array d d_i denote depth sea meter shore 1 le le nLike beach tide intensity tide measure parameter k affect depth begin time t0 follow way for total k second second tide increase depth 1 then total k second second tide decrease depth 1 this process repeat ie depth increase k second decrease k second Formally let define 0indexed array p 0 1 2 ldot k 2 k 1 k k 1 k 2 ldot 2 1 length 2k at time t 0 le t depth meter shore equal d_i pt bmod 2k t bmod 2k denote remainder division t 2k note change occur instantaneously second note well understanding at time t0 Koa standing shore want island suppose time t 0 le t x 0 le x le n meter shore in second Koa swim 1 meter shore x change x1 swim x stay case t change t1 as Koa bad swimmer depth sea point can not exceed l integer point time drown more formally Koa x 1 le x le n meter shore moment t integer tge 0 depth sea point d_x pt bmod 2k can not exceed l in word d_x pt bmod 2k le l hold once Koa reach island n1 meter shore stop restnote Koa swim tide do not effect ie can not drown swimming Note Koa choose stay shore long need shore island affect tide solid ground will not drown Koa wants know shore island help