Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>typedef long long LL;struct node {int key;int siz;int val;int add;LL sum;node* lson;node* rson;int cmp(int x) {int cnt = lson->siz + 1;if( x == cnt ) return -1;return x < cnt? 0: 1;}void pushdown() {if( !add ) return;lson->update(add);rson->update(add);add = 0;}void update(int add) {if( this->lson == NULL ) return;this->add += add;this->val += add;