C题也可以用势能线段树解决: #include<cstdio> #include<cstring> #include<algorithm> #define ls u << 1 #define rs u << 1 | 1 using namespace std; typedef long long LL; const int N = 1e5 + 10, mod = 1e9 + 7; const LL INF = 0x3f3f3f3f3f3f3f3f; int a[N]; int n, m; struct Node { L...