If you think the editorial or your own solution is too complex, you can find the simplest submission record of this question through Solution Size, Many people don't know this.
For example, we can find a code that last div1 C without segment tree
https://codeforces.net/contest/1785/status?order=BY_PROGRAM_LENGTH_ASC