Блог пользователя machhra

Автор machhra, история, 5 лет назад, По-английски

Why did this solution TLE but it passed when I converted the lambda functions to normal ones? Am I doing something wrong here or can lambda functions have this big an overhead?

  • Проголосовать: нравится
  • +28
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +67 Проголосовать: не нравится

Your pragmas are the culprit. Remove them and you'll get AC. Submission: https://codeforces.me/contest/1580/submission/138986509

Lambda functions are not to blame here.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

I'm not sure about your particular scenario but in general lambda functions are a zero cost abstraction.

In fact, due to their narrower scope, the compiler can make stronger assumptions about their use, leading to better optimizations.