Unknown rejection error in snckql19

Hello i’ve some problems submitting this contest Snackdown 2019

When i test my code in the IDE of codechef with 50 testcases it gives me the good result in less than 0.02 s and memory less than 50K

But when i submit in codechef i have two differents errors:

Either time limit reached
Or NZEC error

Both errors appear randomly

//