#include #include #include #include #include #include using namespace std; const int mx=100005; int dp[mx]; int a[mx]; struct Tree { int l,r; int v,m; }; Tree tree[mx*4]; struct S { int di,x; }; S s[mx]; bool com1(S a,S b) { return a.x