第一题有O(n)的做法,见https://loj.ac/problem/6191/statistics/fastest
(不过我不会)