题目链接:http://codeforces.com/problemset/problem/549/F

题目分类:分治

程序链接:http://codeforces.com/contest/549/submission/11590844