AtCoder Beginner Contest 465 problem C
problem link: https://atcoder.jp/contests/abc465/tasks/abc465_c
idk why the editorial algorithm looks just so out of the blue...can someone pls explain how one could've thought about it from scratch? (time limit requires a O(n) solution)