Problem link: 1654C - Алиса и торт
I tried solving the problem with a different approach. It would be great if someone helps me analyze the time and space complexity of my submission, because I feel it should be within constraints and somehow it fails!
Thanks for your time reading :)
Problem solved: see ACGN reply








You are getting a MLE because you are using
std::mapsee my reply below
Your program probably ran into an infinite loop because your variables
valandoddvaloverflowedint.AC submission by replacing
intwithlong longin your declaration ofvalandoddval: 152648929By the way,
std::maps do not cause MLE sincestd::mapalso has space complexity O(n). An infinite loop, on the other hand, creates a large call stack which leads to MLE.that's why
#define int long longis usefulwhat do you think about
#define int shortas suggested by Sparky Masteri think you can