A problem related to open and close interval trick

Hi everyone, I’m stuck in this problem for over 2 days: [CSES - Coding Company](https://Coding Company)

Please help me deeply understand this problem, I actually read about the open-close interval trick on some websites but still too hard to understand.